Skip to content

Instantly share code, notes, and snippets.

@enjikaka
Last active November 17, 2016 09:36
Show Gist options
  • Save enjikaka/b72e6665138cb18f98ce3d9bbf3da174 to your computer and use it in GitHub Desktop.
Save enjikaka/b72e6665138cb18f98ce3d9bbf3da174 to your computer and use it in GitHub Desktop.
Reusable template strings
// Reusable template strings
// JSON and template literals
String.template = (template, data) => new Function('return `'+template+'`').call(data);
/*
String.template("Hello ${this.name}", { name: 'Jeremy' });
Would return "Hello Jeremy"
*/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment