Skip to content
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

Merged
merged 1 commit into from
May 14, 2018
Merged

fix for overwriting partials #310

merged 1 commit into from
May 14, 2018

Conversation

marek-nogiec
Copy link
Contributor

Hi, this is related to #302
I took the approach suggested in that issue (returning new partials in the cb of readPartials) and merging that with copied options.
let me know what you think

Copy link
Collaborator

@doowb doowb left a 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));
Copy link
Collaborator

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.

Copy link
Contributor Author

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

Copy link
Collaborator

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.

}
var tmpl = cache(options) || cache(options, engine.template(str, null, options));
cb(null, tmpl(options).replace(/\n$/, ''));
const optionsCopy = extend({}, options);
Copy link
Collaborator

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.

readPartials(path, options, function(err) {
readPartials(path, options, function(err, partials) {
var extend = (requires.extend || (requires.extend = require('util')._extend));
var optionsCopy = extend({}, options);
Copy link
Collaborator

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.

@doowb
Copy link
Collaborator

doowb commented May 14, 2018

@marek-nogiec thanks for the PR! I'll try to get this published soon.

@doowb doowb merged commit 887fe28 into tj:master May 14, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants