Skip to content

Commit

Permalink
Use correct extension config with Handlebars
Browse files Browse the repository at this point in the history
refs #3559
  • Loading branch information
sgress454 committed Feb 9, 2016
1 parent 55e1237 commit 3cd5d33
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions lib/hooks/views/layoutshim.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@ module.exports = function layoutshim (sails) {
// Get the view engine name
var engineName = sails.config.views.engine.name || sails.config.views.engine.ext;

// Get the extension
var extension = sails.config.views.engine.ext || sails.config.views.extension;

// Use ejs-locals for all ejs templates
if (engineName === 'ejs') {
var ejsLayoutEngine = require('ejs-locals');
Expand All @@ -34,10 +37,10 @@ module.exports = function layoutshim (sails) {
var exphbs = require('express-handlebars');
sails.log.verbose('Overriding handlebars engine with express-handlebars to implement layout support...');
var hbs = exphbs.create({
defaultLayout: path.join('..', (sails.config.views.layout + '.' + (sails.config.views.extension || 'handlebars')) || ''),
defaultLayout: path.join('..', (sails.config.views.layout + '.' + (extension || 'handlebars')) || ''),
helpers: sails.config.views.helpers || {},
partialsDir: path.join('views', sails.config.views.partials || ''),
extname: sails.config.views.extension
extname: extension || 'handlebars'
});

sails.config.views.engine.fn = hbs.engine;
Expand Down

0 comments on commit 3cd5d33

Please sign in to comment.