在快递中禁用视图caching中的帕格(翡翠)模板
我用"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
function时,它只渲染模板。 如果我改变帕格模板,我会根据已经编译好的模板得到旧的页面版本。 对于开发的目的,我需要expression为每个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));