Skip to content

Instantly share code, notes, and snippets.

@datfaf
Forked from ashaw/stringSupplant.js
Created December 13, 2012 19:01
Show Gist options
  • Save datfaf/4278749 to your computer and use it in GitHub Desktop.
Save datfaf/4278749 to your computer and use it in GitHub Desktop.
// thx: https://github.com/bcherry/twitter-text-js/blob/master/twitter-text.js
var stringSupplant = function(str, values) {
return str.replace(/#\{(\w+)\}/g, function(match, name) {
return values[name] || "";
});
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment