EJS:如何在模板中调用多个函数

时间:2019-11-16 04:47:31

标签: node.js express ejs

我是Express的新手,并且具有以下功能:

function diffSummary(o1, o2) {

          res = (o1.sample_id === o2.sample_id) && (o1.v_id === o2.v_id) && (o1.type === o2.type) && (o1.sf === o2.sf) && (o1.ef === o2.ef) && (o1.breakpoint1 === o2.breakpoint1) && (o1.breakpoint2 === o2.breakpoint2);

          res1 = (o1.sge === o2.sge) && (o1.ege === o2.ege) && (o1.som === o2.som) && (o1.wgs === o2.wgs) && (o1.inframe === o2.inframe) && (o1.platform === o2.platform);

          res2 = (o1.rnaconf === o2.rnaconf) && (o1.reportable === o2.reportable) && (o1.targetable === o2.targetable) && (o1.path === o2.path) && (o1.evidence === o2.evidence) && (o1.comments === o2.comments) && (o1.summary !== o2.summary);

          if(res && res1 && res2) {
              return true;
          } else {
              return false;
          }
      }



function isEqual(o1, o2) {

              res = (o1.sample_id === o2.sample_id) && (o1.v_id === o2.v_id) && (o1.type === o2.type) && (o1.sf === o2.sf) && (o1.ef === o2.ef) && (o1.breakpoint1 === o2.breakpoint1) && (o1.breakpoint2 === o2.breakpoint2);

              res1 = (o1.sge === o2.sge) && (o1.ege === o2.ege) && (o1.som === o2.som) && (o1.wgs === o2.wgs) && (o1.inframe === o2.inframe) && (o1.platform === o2.platform);

              res2 = (o1.rnaconf === o2.rnaconf) && (o1.reportable === o2.reportable) && (o1.targetable === o2.targetable) && (o1.path === o2.path) && (o1.evidence === o2.evidence) && (o1.comments === o2.comments) && (o1.summary === o2.summary);

              if(res && res1 && res2) {
                  return true;
              } else {
                  return false;
              }
          }

我有一个server.js文件,我正在通过该文件传递要在EJS模板中呈现的数据。但是,我不确定将这些功能传递给EJS模板的最佳方法是什么。我读过其他问题,在名为app.locals的文件中使用app.js。但是,如果确实在app.js文件中定义了函数,如何将其包含在server.js文件中,以便可以将其传递给模板?任何见解都会受到赞赏。

0 个答案:

没有答案