不知道为什么。
const ejs=require('ejs'),
fs=require('fs'),
path=__dirname+'/time.html';
var str = fs.readFileSync(path , 'utf8');
var restr=ejs.render(str, {
names: ['foo', 'bar', 'baz'] ,
filename: path //加上这个属性 <% include xx %> 就不报错了
});
console.log(restr);
我单独用ejs 的时候也报了同样的错误,然后在加上 filename 这个属性后 就没事了
5 回答4.8k 阅读✓ 已解决
4 回答2.4k 阅读✓ 已解决
2 回答1.7k 阅读✓ 已解决
5 回答1.9k 阅读
2 回答1.3k 阅读✓ 已解决
3 回答2k 阅读
1 回答3.2k 阅读
https://github.com/okonet/ejs...
贴个链接,摘抄下
Including nested templates
Lodash template function does not provide include method of ejs module. To include other templates, passing template functions as parameters does the job. For example:
补充下______
https://doc.webpack-china.org...
高级选项
如果你需要传递更多高级选项,特别是那些不能被字符串化,你还可以在 webpack.config.js 中定义一个 htmlLoader 属性:
这些我们可以通过设置ignoreCustomFragments 属性组定义过滤,比如最近的我的项目使用"webpack": "^2.3.3",