Ryan Burnette Ryan Burnette - 1 year ago 231
CoffeeScript Question

Does Coffeescript always use ES6 Template Literals when compiling instances of string interpolation?

If you use string interpolation in Coffeescript...

# source.coffee
bar = "Bar"
console.log "Foo #{bar}"

It compiles to

# compiled.js
var bar = 'Bar';
console.log(`Foo ${bar}`);

What version of Coffeescript started started compiling string interpolation into ES6 Template Literals? Is there a setting to have Coffeescript compile the old way? I also have to get on my soap box about this. The purpose of template literals was to make JavaScript easier to write by a human. So why was this change made in the compiled output? The old way Coffee compiled this was way more widely supported.

I'm actually using
and I ran into this. If there's a setting for the grunt task as well I'd appreciate the tip.

Answer Source

It's coffeescript 2 vs 1. I just tested it, the old version returns the concatenated string and the new one returns ES6 template literals.

Not sure how you ended up using coffeescript 2 on accident. It's in npm under a different package name (coffeescript for v2 vs coffee-script for v1).

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download