Skip to content

Instantly share code, notes, and snippets.

@darkfe
Created November 21, 2012 14:14
Show Gist options
  • Save darkfe/4125029 to your computer and use it in GitHub Desktop.
Save darkfe/4125029 to your computer and use it in GitHub Desktop.
simple replacer
function replacer(str, obj){
return str.replace(/@{(\w+)}/g,function($all,$1){
return obj[$1] === 0 ? 0 : (obj[$1] || '');
})
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment