Created
November 22, 2015 16:43
-
-
Save replete/0e664e7060c3c348b16d to your computer and use it in GitHub Desktop.
Allows strings to be parsed as if they were ES6 `template string interpolations`.
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
// [email protected] | |
// Method for rendering normal strings as if they were ES6 `template strings like ${this}` | |
String.prototype.toTemplate = function() { return this.replace(/(\$\{.*?\})/g, m => eval('`'+m+'`')) }; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment