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

Transform Ember.String.fmt with ES6 string interpolation #36

Open
abuiles opened this issue May 12, 2015 · 5 comments
Open

Transform Ember.String.fmt with ES6 string interpolation #36

abuiles opened this issue May 12, 2015 · 5 comments

Comments

@abuiles
Copy link
Owner

abuiles commented May 12, 2015

No description provided.

@Serabe
Copy link
Contributor

Serabe commented Jul 10, 2015

I'm thinking about using the following transformation:

const str = Ember.String.fmt("a @2 b @1 c @ d", a, b, c);

into

let _watson1;

{
  let _opts = [a, b, c];
  _watson1 = `a ${_opts[1]} b ${_opts[0]} c ${_opts[0]} d`;
}
const str = _watson1;

This transformation only needs to generate a unique reference: _watson1.

Any thoughts?

@kamal
Copy link
Collaborator

kamal commented Jul 10, 2015

I'd prefer it to transform it in place, so

const str = Ember.String.fmt("a @2 b @1 c @ d", a, b, c);

into

const str = "a ${a} b ${b} c ${c} d";

@knownasilya
Copy link
Collaborator

Yes, that looks much better.

@Serabe
Copy link
Contributor

Serabe commented Jul 10, 2015

@kamal your code would transform into:

const str = `a ${b} b ${a} c ${a} d`

And what happens if a, b or care function calls that we do not expect to be called twice?

@dgavey
Copy link

dgavey commented Apr 18, 2016

Just wondering if the ability to transform the .fmt string prototype has been included in watson yet?

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

No branches or pull requests

5 participants