-
-
Save djalmajr/a1dd48050b680d93581e2be1814d7338 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