Skip to content

Instantly share code, notes, and snippets.

@Elevista
Last active March 4, 2016 06:57
Show Gist options
  • Save Elevista/6d72897f8dbd05e87d4f to your computer and use it in GitHub Desktop.
Save Elevista/6d72897f8dbd05e87d4f to your computer and use it in GitHub Desktop.
ES5 Template literals

##Example

var a = 10, b = 20;
eval(_t)( "${a} * ${b} = ${a * b}" ); //in ES6 `${a} * ${b} = ${a * b}` 
//returns "10 * 20 = 200"
_t = "(function(){return arguments[0].replace(/\\${([^}]+)}/g,function(){return eval(arguments[1])})})";
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment