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

[GPT-526] Dynamic requires of oc-templates #415

Merged
merged 2 commits into from
Mar 23, 2017
Merged

[GPT-526] Dynamic requires of oc-templates #415

merged 2 commits into from
Mar 23, 2017

Conversation

nickbalestra
Copy link
Contributor

No description provided.

if (type === 'jade') { type = 'oc-template-jade'; }
if (type === 'handlebars') { type = 'oc-template-handlebars'; }

// dynamically require specific oc-template
Copy link
Member

Choose a reason for hiding this comment

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

I would remove this comment. If this is the only thing in the try, I think it's quite clear what's happening here.

var ocTemplate;
try {
if (type === 'jade') { type = 'oc-template-jade'; }
if (type === 'handlebars') { type = 'oc-template-handlebars'; }
Copy link
Member

Choose a reason for hiding this comment

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

can we move these ifs out of the try so it's clear the fail can happen only on the require line

throw format(settings.templateNotSupported, type);
}

cb(null, ocTemplate.getCompiledTemplate(templateText, template.key));
Copy link
Member

Choose a reason for hiding this comment

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

I am thinking that these 5 lines of code are actually repeated 4 times. Given we need them for both npm modules (oc and oc-client) - what about moving it to its own npm module, like oc-require-templates so that we can just require it all the times? If that doesn't require too much time obviously?
If not, I would just move it to its own file, like oc-require-templates.js and duplicate it inside the /client and /src folders.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I would go with #2 for the moment so that we don't spread around too many pieces. Once out of 'flux', this could definitely go in its own npm module.

@nickbalestra
Copy link
Contributor Author

@matteofigus all points should be addressed

@matteofigus matteofigus merged commit ff87386 into master Mar 23, 2017
@matteofigus matteofigus deleted the gpt-526 branch March 23, 2017 11:14
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