Please remove defaultLayout
See original GitHub issuePreviously there were no defined defaultLayout and it was ok. But now we have:
function ExpressHandlebars(config) { // Config properties with defaults. utils.assign(this, { handlebars : Handlebars, extname : '.handlebars', layoutsDir : undefined, // Default layouts directory is relative to
express settings.view+
layouts/ partialsDir : undefined, // Default partials directory is relative to
express settings.view+
partials/ defaultLayout : 'main', helpers : undefined, compilerOptions: undefined, }, config);
That cause not natural behaviour in render view:
`ExpressHandlebars.prototype.renderView = function (viewPath, options, callback) {
…
// Pluck-out ExpressHandlebars-specific options and Handlebars-specific
// rendering options.
options = {
cache : options.cache,
view : view,
layout: ‘layout’ in options ? options.layout : this.defaultLayout,
data : options.data,
helpers : helpers,
partials: partials,
};
this.render(viewPath, context, options)
.then(function (body) {
**// Here I receive good hml template body, but while
// (layout: 'layout' in options ? options.layout : this.defaultLayout,)
// and defaultLayout is always specified by default to 'main' then no way to return correct body
//and layoutPath pointing to main which is bad behaviour because we then need manually set
//defaultLayout: false ()
// Register `hbs` as our view engine using its bound `engine()` function.
//app.engine("hbs", hbs({
// defaultLayout: false,
// layoutsDir: "views/",
// extname: ".hbs"
//}));
//app.set("view engine", "hbs");**
var layoutPath = this._resolveLayoutPath(options.layout);
if (### layoutPath) {
return this.render(
layoutPath,
utils.assign({}, context, {body: body}),
utils.assign({}, options, {layout: undefined})
);
}
**return body;**
}.bind(this))
.then(utils.passValue(callback))
.catch(utils.passError(callback));
…`
Issue Analytics
- State:
- Created 4 years ago
- Reactions:4
- Comments:8
Top GitHub Comments
Sure, but we still need this to be fixed since it’s a breaking change.
The defacto standard is semver in the JS / npm world that means
Of course authoring libraries is tough so the duty is shared : we all need to be aware that mistake can be made and we need to test our upgrade. Even some big guys like the React team can had bugs in new release.
At our level we can alert the author and help him fix the bug either by PR, tests, feedbacks, … then wait 😃