Template literals in Coffeescript
While in ES2015/ES6 the way to access template literals is in the way:
var k = 'whatever'
console.log(`I just said ${k}`);
//output: 'I just said whatever'
In CoffeeScript one must write the string between double quotes and change $ for a #.:
k = 'whatever'
console.log "I just said #{k}"
//output: 'I just said whatever'.
If written in single quotes, it will output:
//'I just said #{k}'
Directly.
Written by Esteban
Related protips
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
#Coffeescript
Authors
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#