我已經將swig添加爲我的KeystoneJS項目的模板引擎,但它不會加載我的模板。我已經添加了以下到我的keystone.js文件:將swig作爲模板引擎添加到keystoneJS
// Require keystone
var keystone = require('keystone');
var swig = require('swig');
// Initialise Keystone with your project's configuration.
// See http://keystonejs.com/guide/config for available options
// and documentation.
keystone.init({
'name': 'it_blog',
'brand': 'it_blog',
'less': 'public',
'static': 'public',
'favicon': 'public/favicon.ico',
'views': 'templates/views',
'view engine': 'swig',
'custom engine': swig.renderFile,
'auto update': true,
'session': true,
'auth': true,
'user model': 'User',
'cookie secret': '*omitted*'
});
這裏是Node.js的錯誤,我得到:
Error thrown for request:/
Error: Failed to lookup view "index"
at Function.app.render (/Users/admin/Desktop/Development/my_project/node_modules/keystone/node_modules/express/lib/application.js:495:17)
我跟着列出的步驟操作:https://github.com/JedWatson/keystone/issues/270
快遞做一些瘋狂的事情與文件擴展名。它會自動試圖找到'index.swig',但你的文件是'index.html'? –
@PaulArmstrong沒有運氣使用.swig文件 – RandomDeduction