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

Can't use ES6 tagged template literals embedded in Coffeescript #4301

Closed
greghuc opened this issue Sep 1, 2016 · 2 comments
Closed

Can't use ES6 tagged template literals embedded in Coffeescript #4301

greghuc opened this issue Sep 1, 2016 · 2 comments

Comments

@greghuc
Copy link
Contributor

greghuc commented Sep 1, 2016

Use of ES6 tagged template literals is currently broken in Coffeescript, unless I'm missing a trick.

Since tagged template literals are not directly supported in Coffeescript, the obvious way of using them is to embed the Javascript directly, like:

`
 var a = 5;
 var b = 10;

 function tag(strings, ...values) {
   return "Bazinga!";
 };

 tag`Hello ${ a + b } world ${ a * b }`;
`

However, testing this code on http://js2.coffee, I'm seeing 'unexpected identifier' error on the final "tag" line.

I'm assuming the root cause is that backticks are already used by Coffeescript to mark the start and end of the embedded Javascript section. As such, backticks can't also be used inside the embedded Javascript to make the tagged template literal call.

FYI, I ran into this problem when exploring the newish bel DOM templating library. Since it uses tagged template strings, I believe it's inoperable with current Coffeescript. This is the first time I've seen incompatibility between Coffeescript and Javascript..

@greghuc
Copy link
Contributor Author

greghuc commented Sep 1, 2016

Some related discussion from a bug opened in July 2011: #1504

@GeoffreyBooth
Copy link
Collaborator

Added by #4352

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

2 participants