譬如在index.html 中引用 header.html 和 footer.html
-- index.html -- public |-- header.html |-- footer.html
用{{#def.loadfile('public/header.html')}} 报错啊,
500 TypeError: Object # has no method 'loadfile'
大神支招啊!
回复 (1)
A
你需要自己定义loadfile方法 比如:
var defs = {};
defs.loadfile = function(path) {
var data = fs.readFileSync(path);
if (data) return data.toString();
console.log("file not found with path: " + path);
}
然后dot编译阶段将defs传入就行
dot.template(view, options, defs)
参与回复
登录后即可参与回复。登录