From 3cd5d3353105d726e28c2ed9689661e9a86e3f58 Mon Sep 17 00:00:00 2001 From: Scott Gress Date: Tue, 9 Feb 2016 15:35:38 -0600 Subject: [PATCH] Use correct extension config with Handlebars refs #3559 --- lib/hooks/views/layoutshim.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/lib/hooks/views/layoutshim.js b/lib/hooks/views/layoutshim.js index 79753c88d..a098712e9 100644 --- a/lib/hooks/views/layoutshim.js +++ b/lib/hooks/views/layoutshim.js @@ -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'); @@ -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;