I have added swig as the template engine to my KeystoneJS project but it will not load my templates. I have added the following to my keystone.js file:
// 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*'
});
Here is the node.js error that I get:
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)
I followed the steps listed here: https://github.com/JedWatson/keystone/issues/270
The official Keystone Generator for Yeoman now includes Swig support and example templates, I recommend using that to start a project, selecting swig
as the template engine, and copying its implementation.
Instructions for getting started with the generator are here: http://keystonejs.com/getting-started/