ericf / express-handlebars

A Handlebars view engine for Express which doesn't suck.
BSD 3-Clause "New" or "Revised" License
2.32k stars 382 forks source link

app.engine examples in readme point to differently named engines #232

Open shellandbull opened 5 years ago

shellandbull commented 5 years ago

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

knoxcard commented 5 years ago

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'
  }))
algomis commented 5 years ago

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