thinkjs/lib/Lib/Behavior/ParseTemplateBehavior.js
2014-07-07 18:09:57 +08:00

21 lines
611 B
JavaScript
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

/**
* 调用对应的模版引擎解析模版
* @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);
}
};
});