diff --git a/lib/express-handlebars.js b/lib/express-handlebars.js index 1894e4f..a2a03bf 100644 --- a/lib/express-handlebars.js +++ b/lib/express-handlebars.js @@ -29,6 +29,7 @@ function ExpressHandlebars(config) { defaultLayout : undefined, helpers : undefined, compilerOptions: undefined, + development : false }, config); // Express view engine integration point. @@ -45,6 +46,11 @@ function ExpressHandlebars(config) { // Private internal file system cache. this._fsCache = Object.create(null); + + //Setup partials on the Handlebars global + this.getPartials().then(function(partials) { + Handlebars.registerPartial(partials); + }); } ExpressHandlebars.prototype.getPartials = function (options) { @@ -95,9 +101,13 @@ ExpressHandlebars.prototype.getPartials = function (options) { var partialName = getTemplateName(filePath, namespace); partials[partialName] = templates[filePath]; }); + + if (this.development) { + Handlebars.registerPartial(partials); + } return partials; - }, {}); + }.bind(this), {}); }.bind(this)); };