Skip to content

Instantly share code, notes, and snippets.

@stevebartholomew
Created March 30, 2010 21:20
Show Gist options
  • Save stevebartholomew/349606 to your computer and use it in GitHub Desktop.
Save stevebartholomew/349606 to your computer and use it in GitHub Desktop.
/*
** Template.templates.customer_address = "<div class='address'>${name}, ${line1}, ${postcode}</div>"
**
** var address = jQuery.parseJSON('{"name": "Steve", "line1": test}')
** Template.render("customer_address", address)
**
*/
var Template = {
templates : {},
render : function(name, object) {
template = Template.templates[name];
$.each(object, function(key, value) {
tag = "${"+ key +"}"
template = template.replace(tag, value);
});
return template;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment