-
Notifications
You must be signed in to change notification settings - Fork 383
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add support for render-level partials #107
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -176,11 +176,9 @@ ExpressHandlebars.prototype.render = function (filePath, context, options) { | |
]).then(function (templates) { | ||
var template = templates[0], | ||
partials = templates[1], | ||
helpers = options.helpers || this.helpers, | ||
data = options.data; | ||
|
||
var helpers = options.helpers || | ||
utils.extend({}, this.handlebars.helpers, this.helpers); | ||
|
||
return this._renderTemplate(template, context, { | ||
data : data, | ||
helpers : helpers, | ||
|
@@ -190,11 +188,19 @@ ExpressHandlebars.prototype.render = function (filePath, context, options) { | |
}; | ||
|
||
ExpressHandlebars.prototype.renderView = function (viewPath, options, callback) { | ||
var context = options, | ||
data = options.data; | ||
options || (options = {}); | ||
|
||
var context = options; | ||
var data = options.data; | ||
|
||
var helpers = utils.extend({}, | ||
this.handlebars.helpers, this.helpers, options.helpers); | ||
var helpers = utils.extend({}, this.helpers, options.helpers); | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I removed the merge of |
||
var partials = Promise.all([ | ||
this.getPartials({cache: options.cache}), | ||
Promise.resolve(options.partials) | ||
]).then(function (partials) { | ||
return utils.extend.apply(null, [{}].concat(partials)); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Used |
||
}); | ||
|
||
// Pluck-out ExpressHandlebars-specific options. | ||
options = { | ||
|
@@ -207,7 +213,7 @@ ExpressHandlebars.prototype.renderView = function (viewPath, options, callback) | |
utils.extend(options, { | ||
data : data, | ||
helpers : helpers, | ||
partials: this.getPartials(options) | ||
partials: partials | ||
}); | ||
|
||
this.render(viewPath, context, options) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I removed the merge of
this.handlebars.helpers
since Handlebars will do this merge automatically at render time.