express-handlebars
express-handlebars copied to clipboard
app.engine examples in readme point to differently named engines
Overly minor but, noticed the following reading through the docs:
app.engine('handlebars', exphbs({defaultLayout: 'main'}));
app.engine('handlebars', hbs.engine);
app.engine('handlebars', hbs.engine);
app.engine('.hbs', exphbs({extname: '.hbs'}));
app.engine('handlebars', exphbs({defaultLayout: 'main'}));
Is the engine we should set using the lib handlebars or .hbs? Happy to contribute a readme fix
I've using ".hbs" for the last two years...
app.engine('.hbs', require('express-handlebars')({
defaultLayout: '',
extname: '.hbs',
helpers: require(require('path').join(__dirname, 'lib/helpers.js')).helpers,
layoutsDir: require('path').join(__dirname, 'templates/layouts'),
partialsDir: __dirname + '/templates/partials'
}))
Agree that the docs is not being explicit enough. This is the setting that made it work for me with the understanding that my views are within my app directory:
app.engine('hbs', exphbs({ defaultLayout: 'main', extname: '.hbs', layoutsDir: 'app/views/layouts', partialsDir: 'app/views/partials' })); app.set('views', 'app/views/') app.set('view engine', 'hbs');