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

Replace Lodash templates #1810

Closed
Shou opened this issue Oct 25, 2017 · 5 comments
Closed

Replace Lodash templates #1810

Shou opened this issue Oct 25, 2017 · 5 comments

Comments

@Shou
Copy link
Contributor

Shou commented Oct 25, 2017

Instead we could simply use lambdas and native template literals, e.g.

const tplt = _.template('I am a <%= adjective %> template.')
tplt({ adjective: 'small' })

const tplt = ({ adjective }) => `I am a ${adjective} template.`
tplt({ adjective: 'small' })
@lurch
Copy link
Contributor

lurch commented Oct 25, 2017

Would this change have any knock-on effects if/when we decide to localize Etcher? ( #308 )

@Shou
Copy link
Contributor Author

Shou commented Oct 25, 2017

Can't see how, I don't believe _.template has any functionality that localization could leverage.

Edit: Ah, I see what you mean now. Because they're pure strings it would be possible to keep them in separate files and also without worrying about injection of other variables, assuming that could be dangerous.

@lurch
Copy link
Contributor

lurch commented Oct 25, 2017

Fair enough :) I just wondered if searching for _.template might be a useful way to find strings that ought to be localised, but thinking about it a bit more I guess there'll also be plenty of strings that we need to localise that aren't templated.

@jhermsmeier
Copy link
Contributor

jhermsmeier commented Oct 25, 2017

In terms of localization, string templates could be easily fitted with it by sticking a tag function in front of it (see tagged template literals), far easier than mending lodash templates.

@urohit011
Copy link

I would like to work on this.

urohit011 added a commit to urohit011/etcher that referenced this issue Nov 1, 2017
urohit011 added a commit to urohit011/etcher that referenced this issue Nov 19, 2017
style: fixed linter errors

style: fixed linter errors

refactor: remove enclosing array brackets.

remove enclosing array brackets for single string.

refactor: replace lodash templates balena-io#1810
@jviotti jviotti added this to the Backlog milestone Dec 5, 2017
Shou pushed a commit that referenced this issue Jan 29, 2018
We replace the lodash templates with arrow-functions and change the
single-argument object into multiple arguments.

Change-Type: patch
Changelog-Entry: Replace Lodash templates with arrow-functions.
Shou pushed a commit that referenced this issue Jan 29, 2018
We replace the lodash templates with arrow-functions and change the
single-argument object into multiple arguments.

Change-Type: patch
Changelog-Entry: Replace Lodash templates with arrow-functions.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants