5
所以我试图用consolidate.js呈现swig templates与快递,但我得到以下错误,当我尝试“扩展”从另外一个模板:无法呈现痛饮模板快速
Error: ENOENT, no such file or directory '//one.html
在我app.js
文件我设置痛饮作为我的渲染引擎(仅包括相关的代码):
var consolidate = require('consolidate');
app.set('view engine', 'html');
app.set('views', __dirname + '/views');
app.engine('.html', consolidate.swig);
app.get('/test', function(req, res) {
res.render('two');
});
而且我有一个基本模板,one.html
:
<h3>My Site</h3>
{% block content %}
Welcome
{% endblock %}
然后,一个继承模板,two.html
:
{% extends 'one.html' %}
{% block content %}
This is an inner page.
{% endblock %}
那么,为什么痛饮找one.html
与//one.html
路径(如上面的错误?)感谢您的帮助。
你不需要使用整合,只需[使用'swig.renderFile'as引擎](http://paularmstrong.github.io/swig/docs/#express)=>'app.engine('html',swig.renderFile);' – laconbass
请注意'swig.init'在最新版本的swig中已弃用。有关其他选项,请参见[swig文档](http://paularmstrong.github.io/swig/docs/api/#SwigOpts) – user1534980