4 个回答

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",

  <%- include('footer') %>

语法写错了

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 这个属性后 就没事了

新手上路,请多包涵

请问一下,你解决了这个问题吗?

撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题