From cf9eb5bc4d4853140e30a078ab6ce29453620738 Mon Sep 17 00:00:00 2001 From: Hannah Wolfe Date: Tue, 10 Mar 2015 15:52:00 +0000 Subject: [PATCH] Use partialIndent hbs option to prevent indent issues fix #4364 --- core/server/middleware/index.js | 13 ++++++++++++- package.json | 2 +- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/core/server/middleware/index.js b/core/server/middleware/index.js index b3cbf140828..7992a7f053e 100644 --- a/core/server/middleware/index.js +++ b/core/server/middleware/index.js @@ -52,7 +52,18 @@ function activateTheme(activeTheme) { blogApp.cache = {}; // set view engine - hbsOptions = {partialsDir: [config.paths.helperTemplates]}; + hbsOptions = { + partialsDir: [config.paths.helperTemplates], + // override the default compile + onCompile: function(exhbs, source, filename) { + var options; + if (filename && filename.indexOf('partials') !== -1) { + options = {preventIndent: true}; + } + + return exhbs.handlebars.compile(source, options); + } + }; fs.stat(themePartials, function (err, stats) { // Check that the theme has a partials directory before trying to use it diff --git a/package.json b/package.json index 58a56bf2530..95a340ba146 100644 --- a/package.json +++ b/package.json @@ -43,7 +43,7 @@ "connect-slashes": "1.3.0", "downsize": "0.0.8", "express": "4.12.0", - "express-hbs": "0.7.11", + "express-hbs": "0.8.2", "extract-zip": "1.0.3", "fs-extra": "0.13.0", "glob": "4.3.2",