Skip to content

Instantly share code, notes, and snippets.

@katspaugh
Created November 17, 2011 10:59
Show Gist options
  • Save katspaugh/1372908 to your computer and use it in GitHub Desktop.
Save katspaugh/1372908 to your computer and use it in GitHub Desktop.
String.prototype.template
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