Javascript 将swig作为模板引擎添加到keystoneJS
我已经将swig作为模板引擎添加到我的KeystoneJS项目中,但它不会加载我的模板。我已将以下内容添加到我的keystone.js文件中:Javascript 将swig作为模板引擎添加到keystoneJS,javascript,node.js,template-engine,swig-template,keystonejs,Javascript,Node.js,Template Engine,Swig Template,Keystonejs,我已经将swig作为模板引擎添加到我的KeystoneJS项目中,但它不会加载我的模板。我已将以下内容添加到我的keystone.js文件中: // Require keystone var keystone = require('keystone'); var swig = require('swig'); // Initialise Keystone with your project's configuration. // See http://keystonejs.com/guide/
// 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)
我遵循了这里列出的步骤:Yeoman官方现在包括Swig支持和示例模板,我建议使用它来启动一个项目,选择Swig
作为模板引擎,并复制其实现
使用生成器的说明如下:Express使用文件扩展名做了一些疯狂的事情。它是否自动尝试查找
index.swig
,但您的文件是index.html
?@PaulArmstrong使用.swig文件真是太棒了!谢谢你,杰德。这是对已经很好的KeystoneJS包的一个很好的补充。