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

CS2 Discussion: Output: ES6 template literals for CoffeeScript interpolated strings #4937

Closed
coffeescriptbot opened this issue Feb 19, 2018 · 1 comment

Comments

@coffeescriptbot
Copy link
Collaborator

From @greghuc on 2016-09-20 18:10

As discussed here, I'm splitting out a separate issue for compiling Coffeescript interpolated strings to ES6 template literals.

In short, Coffeescript single-line, multi-line and block interpolated strings can all be compiled to ES6 template literals. To note:

  • This change feels like 'Coffeescript 2.0', as it uses an ES6 feature for an existing Coffeescript feature. So if you use Coffeescript strings, you won't be able to opt out of ES6.
  • This feature should be implemented after tagged template literals. Implementation of that feature will do most of the heavy lifting on determining how template literals play with Coffeescript.

Examples:

Single-line string:

//CS input
"Hi #{name} Do you like #{food}?"

//ES6 output
`Hi ${name} Do you like ${food}?`;

Multiline string:

//CS input
"Hi #{name}. Do
 you like #{food}?"

//ES6 output
upperExpr`Hi ${name}. Do you like ${food}?`;

Block string:

//CS input
"""
         <strong>
           cup of #{language}
         </strong>
"""

//ES6 output
upperExpr`<strong>\n  cup of ${language}\n</strong>`;
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

1 participant