jashkenas / coffeescript

Unfancy JavaScript
https://coffeescript.org/
MIT License
16.5k stars 1.98k forks source link

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

Closed coffeescriptbot closed 6 years ago

coffeescriptbot commented 6 years ago

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:

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>`;
coffeescriptbot commented 6 years ago

From @GeoffreyBooth on 2016-12-05 01:56

Merged into 2.