Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Allows strings to be parsed as if they were ES6 `template string interpolations`.
// 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
You can’t perform that action at this time.