Skip to content

Instantly share code, notes, and snippets.

@dtanham
Created April 21, 2013 17:41
Show Gist options
  • Save dtanham/5430405 to your computer and use it in GitHub Desktop.
Save dtanham/5430405 to your computer and use it in GitHub Desktop.
Very simple parameter subsitution in JS. Arguments are string containing parameter placeholders and a corresponding object of keys and values. Depends on jQ.
// Return s, with parameters substituted as in key-values of object params
function subsituteParams(s, params) {
$.each(params, function(k,v) {
s = s.replace(k,v);
});
return s;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment