Skip to content

Instantly share code, notes, and snippets.

@datfaf
Forked from tored/supplant.js
Created December 13, 2012 19:01
Show Gist options
  • Save datfaf/4278746 to your computer and use it in GitHub Desktop.
Save datfaf/4278746 to your computer and use it in GitHub Desktop.
function supplant(s, o) {
return s.replace(/\{([^{}]*)\}/g,
function (a, b) {
var r = o[b];
return typeof r === 'string' || typeof r === 'number' ? r : a;
}
);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment