Created
November 17, 2011 10:59
-
-
Save katspaugh/1372908 to your computer and use it in GitHub Desktop.
String.prototype.template
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
String.prototype.template = function (obj) { | |
return this.replace( | |
/{{(.+?)}}/g, | |
function (_, key) { return obj[key] } | |
) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment