-
Notifications
You must be signed in to change notification settings - Fork 24
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
Region Helper - Paper - MERC-2432 #118
Region Helper - Paper - MERC-2432 #118
Conversation
284cfe7
to
edef0a5
Compare
index.js
Outdated
} | ||
_.each(helpers, function (helper) { | ||
helper(self); | ||
}); |
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.
Can you update this code to
helpers.forEach(helper => helper(this));
index.js
Outdated
var self = this; | ||
class Paper { | ||
constructor(settings, themeSettings, assembler) { | ||
let self = this; |
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 don't need self
anymore. You can use this
directly.
index.js
Outdated
eval('template = ' + precompiled); | ||
self.handlebars.templates[path] = self.handlebars.template(template); | ||
Async.parallel([ | ||
function (next) { |
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.
can you make these arrow functions?
index.js
Outdated
if (path[0] !== '/') { | ||
path = '/' + path; | ||
} | ||
if (path.substr(0, 8) === '/assets/') { |
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.
Use RegEx path.match(/^\/assets\//)
index.js
Outdated
var self = this; | ||
// Make translations available to the helpers | ||
translator = Translator.create(data.acceptLanguage, translations); | ||
let instance = new Paper(data.context.settings, data.context.themeSettings, assembler); |
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.
use const
instead
index.js
Outdated
* @param {Function} callback | ||
*/ | ||
loadTemplates(path, callback) { | ||
let self = this; |
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.
Same here. You don't need this anymore. Just make sure to convert all anonymous functions inside this block to use arrow functions
index.js
Outdated
let cdnUrl = this.settings['cdn_url'] || ''; | ||
let versionId = this.settings['theme_version_id']; | ||
let sessionId = this.settings['theme_session_id']; | ||
let protocolMatch = /(.*!?:)/; |
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.
Please use const
on variables that are not reassigned
index.js
Outdated
|
||
return [cdnUrl, 'stencil', versionId, path].join('/'); | ||
}; | ||
_.each(this.decorators, function (decorator) { |
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.decorators.forEach(decorator => {...});
index.js
Outdated
* @return {String|Object} | ||
*/ | ||
renderTheme(templatePath, data) { | ||
let html, |
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.
one let
per variable
index.js
Outdated
return output; | ||
}; | ||
if (data.remote) { | ||
data.context = _.extend({}, data.context, data.remote_data); |
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.
Please use Object.assign
edef0a5
to
f0d4121
Compare
.eslintrc
Outdated
@@ -8,6 +8,7 @@ | |||
}, | |||
"env": { | |||
"node": true, | |||
"es6": true |
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 know that we can do this without upgrading Stapler. @mcampa
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 guess I can remove that. I added it so eslint would stop fussing about Promises, but since I've removed Promises from the code, it's not necessary anymore.
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.
Can you use constructor
in es5? I thought that was an es6 thing.
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 actually already enabled for es6. The original file has this in there.
{
"parserOptions": {
"ecmaVersion": 6,
"sourceType": "module"
},
That addition was only about making Promises global.
f0d4121
to
f1deac9
Compare
Please add node Can you please add node 4 & 6 to travis.yml file? |
dcfa65b
to
adfd154
Compare
index.js
Outdated
this.settings = settings || {}; | ||
this.themeSettings = themeSettings || {}; | ||
this.assembler = assembler || {}; | ||
this.renderingContext = {}; |
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.
Can you name this differently, to be specific to content blocks? Like maybe contentBlocksContext
adfd154
to
56c8e0c
Compare
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.
LGTM. just make sure everything works with the cli and stapler before merging
What:
Add an attribute to Paper to use for rendering store content.
Also - converts Paper to using ES6 style classes.