-
Notifications
You must be signed in to change notification settings - Fork 23
renderTheme method #101
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
renderTheme method #101
Conversation
index.js
Outdated
| if (_.isArray(templatePath)) { | ||
| // if templatePath is an array ( multiple templates using render_with option) | ||
| // compile all the template required files into a hash table | ||
| html = templatePath.reduce(function(table, file) { |
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.
switch yo arrow function syntax, by doing this you can use this and remove the self variable
|
Can you please make the change in stencil-cli as well? And make sure there is no incompatibility when used by the cli |
|
@mcampa - it's been updated to use the arrow function and |
| // if templatePath is an array ( multiple templates using render_with option) | ||
| // compile all the template required files into a hash table | ||
| html = templatePath.reduce((table, file) => { | ||
| table[file] = this.render(file, data.context); |
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 need to set template_file here too, because templatePath is an array in this block.
data.context.template_file = file;
table[file] = this.render(file, data.context);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.
how about table[file] = this.render(file, _.extend({}, data.context, { template_file: file })); instead?
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.
it's been moved to the render method instead. also made sure context defaults to {} so the tests pass
mcampa
left a comment
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.
👍
this method was extracted from stencil-cli:
https://github.com/bigcommerce/stencil-cli/blob/master/server/plugins/renderer/responses/pencil-response.js#L34-L70
it also has an additional line which sets the context template_file field to the templatePath:
https://github.com/bigcommerce/paper/compare/bigcommerce:master...mjschock:MERC-1554?expand=1#diff-168726dbe96b3ce427e7fedce31bb0bcR260