在Express中禁用Pug(Jade)模板的视图缓存

3
我使用的是"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模板,将会得到基于已编译模板的旧页面版本。为了开发目的,我需要在每个render调用时重新编译.pug模板。我该如何实现这一点?
我尝试了以下方式:
app.disable('view cache'); OR
app.set('view cache', false); OR
app.set('view cache', 'disabled');

但是这些都没有帮助到我。
1个回答

1

令人失望,但运行正常:

const pug = require('pug');
const path = require('path');
res.send(pug.renderFile(path.join(__dirname,'template.pug'), templateObj));

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接