我使用"express": "^4.14.0", "pug": "^2.0.0-beta6"
app.set('view engine', 'jade');
...
app.get('/', function (req, res) {
res.render('index.pug', {...});
}
当我使用 Express render
函数时,它仅渲染模板一次。如果我更改 pug-template,我将获得基于已编译模板的旧页面版本。出于开发目的,我需要为每个 render
调用快速重新编译 .pug 模板。我怎样才能实现这个目标?
我尝试过类似的方法:
app.disable('view cache'); OR
app.set('view cache', false); OR
app.set('view cache', 'disabled');
但这些都没有帮助。
最佳答案
令人失望,但工作:
const pug = require('pug');
const path = require('path');
res.send(pug.renderFile(path.join(__dirname,'template.pug'), templateObj));
关于node.js - 在express中禁用pug(jade)模板的 View 缓存,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41073026/