Skip to content

Instantly share code, notes, and snippets.

@kaimallea
Created August 17, 2013 18:02
Show Gist options
  • Save kaimallea/6258016 to your computer and use it in GitHub Desktop.
Save kaimallea/6258016 to your computer and use it in GitHub Desktop.
Supplant
if (typeof String.prototype.supplant !== 'function') {
String.prototype.supplant = function (o) {
return this.replace(/{([^{}]*)}/g, function (a, b) {
var r = o[b];
return typeof r === 'string' ? r : a;
});
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment