Last active
November 17, 2016 09:36
-
-
Save enjikaka/b72e6665138cb18f98ce3d9bbf3da174 to your computer and use it in GitHub Desktop.
Reusable template strings
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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