Created
April 21, 2013 17:41
-
-
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.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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