Skip to content

Conversation

@mjschock
Copy link
Contributor

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) {
Copy link
Contributor

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

@mcampa
Copy link
Contributor

mcampa commented Jan 5, 2017

Can you please make the change in stencil-cli as well? And make sure there is no incompatibility when used by the cli

@mjschock
Copy link
Contributor Author

mjschock commented Jan 5, 2017

@mcampa - it's been updated to use the arrow function and this. i verified that npm test for stencil-cli runs against this branch and stencil start works fine too. there's a PR for the stencil-cli changes: bigcommerce/stencil-cli#262

// 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);
Copy link
Contributor

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);

Copy link
Contributor Author

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?

Copy link
Contributor Author

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

Copy link
Contributor

@mcampa mcampa left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@mjschock mjschock merged commit ca21d86 into bigcommerce:master Jan 5, 2017
@mjschock mjschock deleted the MERC-1554 branch January 5, 2017 22:27
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.

5 participants