Skip to content

Instantly share code, notes, and snippets.

@kriansa kriansa/gist:5885902

Created Jun 28, 2013
Embed
What would you like to do?
Simple Javascript template parser
/**
* Replaces any ${variables} in the template string by the data object
*/
var parseTemplate = function(template, data) {
return template.replace(/\$\{([\w\d]+)\}/g, function(token, variable){
return data[variable];
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.