-
Notifications
You must be signed in to change notification settings - Fork 353
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
fix for overwriting partials #310
Conversation
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.
Thanks. I've added a few change requests, but I think this looks good!
@@ -171,14 +171,17 @@ function fromStringRenderer(name) { | |||
options.filename = path; | |||
|
|||
return promisify(cb, function(cb) { | |||
readPartials(path, options, function(err) { | |||
readPartials(path, options, function(err, partials) { | |||
var extend = (requires.extend || (requires.extend = require('util')._extend)); |
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 don't think this is necessary, you can just use Object.assign
.
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.
you sure? I wasn't sure which version needs to be supported since only extend is used in this lib
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.
thanks for pointing that out... I forgot that it was already used in other places.
lib/consolidate.js
Outdated
} | ||
var tmpl = cache(options) || cache(options, engine.template(str, null, options)); | ||
cb(null, tmpl(options).replace(/\n$/, '')); | ||
const optionsCopy = extend({}, 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 don't think making a copy of options
is necessary here since the copy was already made in fromStringRenderer
above and already has the new partials
object.
lib/consolidate.js
Outdated
readPartials(path, options, function(err) { | ||
readPartials(path, options, function(err, partials) { | ||
var extend = (requires.extend || (requires.extend = require('util')._extend)); | ||
var optionsCopy = extend({}, 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.
just a nitpick... instead of optionsCopy
, change this to opts
.
@marek-nogiec thanks for the PR! I'll try to get this published soon. |
Hi, this is related to #302
I took the approach suggested in that issue (returning new
partials
in the cb ofreadPartials
) and merging that with copiedoptions
.let me know what you think