当与其他视图不在同一文件夹中时,Swig标记在索引文件中不起作用
我有一个与以下结构的应用程序:
- app - views pages includes - index.html
在我的应用程序,我使用这个:
if (env === 'development' || env === 'test') { swig.setDefaults({ cache: false }); } app.engine('html', swig.renderFile); app.set('views', [config.root + '/tmp', config.root + '/tmp/views/includes', config.root + '/tmp/views/pages']); app.set('view engine', 'html');
index.html的:
{% include 'includes/head.html' %}
然而,发生的问题是, index.html
文件中的所有swig标记都不起作用,只是将它们打印出来作为string。 如果我移动views
文件夹内的索引文件,但它工作。
我找不到任何解决办法,有什么可能是错的?
也许尝试预先在app.set('views'...
文件夹的名称app.set('views'...
与__dirname
?