Skip to content

Instantly share code, notes, and snippets.

@amadeus
Created March 15, 2013 23:12
Show Gist options
  • Save amadeus/5173909 to your computer and use it in GitHub Desktop.
Save amadeus/5173909 to your computer and use it in GitHub Desktop.
(function(){
String.prototype.substitute = function(object, regexp){
return String(this).replace(regexp || (/\\?\{([^{}]+)\}/g), function(match, name){
if (match.charAt(0) == '\\') return match.slice(1);
return (object[name] != null) ? object[name] : '';
});
};
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment