Skip to content

Instantly share code, notes, and snippets.

@kekscom
Created February 14, 2014 09:26
Show Gist options
  • Save kekscom/8998221 to your computer and use it in GitHub Desktop.
Save kekscom/8998221 to your computer and use it in GitHub Desktop.
replace tags in a string by matching (primitive) object properties
function pattern(str, param, callback) {
return str.replace(/\{([\w_]+)\}/g, function(tag, key) {
return param[key] || tag;
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment