我将 nunjucks2 与 express 和 node 一起使用,将 njk 升级到 2.4.2 后出现此错误:
Template render error: (/home/aien/Web/Test/express/views/error.html)
Template render error: (/home/aien/Web/Test/express/views/layout.html) [Line 56, Column 20]
expected block end in block statement
at Object.exports.prettifyError (/home/aien/Web/Test/express/node_modules/nunjucks/src/lib.js:34:15)
at /home/aien/Web/Test/express/node_modules/nunjucks/src/environment.js:485:31
at root [as rootRenderFunc] (eval at <anonymous> (/home/aien/Web/Test/express/node_modules/nunjucks/src/environment.js:564:24), <anonymous>:25:3)
at Obj.extend.render (/home/aien/Web/Test/express/node_modules/nunjucks/src/environment.js:478:15)
at /home/aien/Web/Test/express/node_modules/nunjucks/src/environment.js:311:35
at Obj.extend.getTemplate (/home/aien/Web/Test/express/node_modules/nunjucks/src/environment.js:194:17)
at Obj.extend.render (/home/aien/Web/Test/express/node_modules/nunjucks/src/environment.js:303:14)
at NunjucksView.render (/home/aien/Web/Test/express/node_modules/nunjucks/src/environment.js:284:15)
at tryRender (/home/aien/Web/Test/express/node_modules/express/lib/application.js:639:10)
at EventEmitter.render (/home/aien/Web/Test/express/node_modules/express/lib/application.js:591:3)
错误和布局是简单的 nunjucks 文件,在这里我发布我的app.js
配置:
app.set('views', path.join(__dirname, 'views'));
nunjucks.configure('views', {
express: app,
autoescape: true
});
app.set('view engine', 'html');