【发布时间】:2016-05-27 08:09:55
【问题描述】:
我在我的节点 js 项目中使用 ejs,并为类似的视图使用 html 模板
app.engine('html', require('ejs').renderFile); app.set('view engine', 'html');
我想将 layout.html 用于我的其他页面,如何扩展它?谢谢!
【问题讨论】:
我在我的节点 js 项目中使用 ejs,并为类似的视图使用 html 模板
app.engine('html', require('ejs').renderFile); app.set('view engine', 'html');
我想将 layout.html 用于我的其他页面,如何扩展它?谢谢!
【问题讨论】:
您可以使用 ejs 或 ejs local 作为引擎。
在您的应用中:
app.engine('ejs', require('ejs-locals'));
app.set('view engine', 'ejs');
在创建模板文件为 .ejs 之后 并且在您的其他 .ejs 文件中需要这样的模板:
<% layout('template.ejs') -%>
【讨论】: