# Code coverage report for thinkjs/lib/Lib/Behavior/ParseTemplateBehavior.js

## Statements: 100% (9 / 9) Branches: 100% (2 / 2) Functions: 100% (2 / 2) Lines: 100% (9 / 9) Ignored: none

All files » thinkjs/lib/Lib/Behavior/ » ParseTemplateBehavior.js

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21

    2

    2

    15

    15
    15

    15
    2

    13
    13

     /**
     * 调用对应的模版引擎解析模版
     * @return {[type]} [description]
     */
    module.exports = Behavior(function(){
      'use strict';
      return {
        run: function(data){
          var file = data.file;
          //将模版文件路径写入到http对象上，供writehtmlcache里使用
          this.http.tpl_file = file;
          var engine = C('tpl_engine_type');
          //不使用模版引擎，直接返回文件内容
          if (!engine) {
            return getFileContent(file);
          }
          var engineClass = ucfirst(engine) + 'Template';
          return thinkRequire(engineClass).fetch(file, data.var);
        }
      };
    });