express-handlebars icon indicating copy to clipboard operation
express-handlebars copied to clipboard

app.engine examples in readme point to differently named engines

Open shellandbull opened this issue 6 years ago • 2 comments

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

shellandbull avatar Jul 12 '18 10:07 shellandbull

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'
}))

knoxcard avatar Sep 28 '18 10:09 knoxcard

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');

algomis avatar Oct 19 '18 13:10 algomis