Skip to content

Instantly share code, notes, and snippets.

@empr
Created September 6, 2012 13:40
Show Gist options
  • Select an option

  • Save empr/3656364 to your computer and use it in GitHub Desktop.

Select an option

Save empr/3656364 to your computer and use it in GitHub Desktop.
wrapper for underscore template.
var Template = (function() {
var _cache = {};
function render(id, params) {
if (_cache[id]) {
return _cache[id](params);
}
$('script[type="text/template"]').each(function(i, e) {
if (id === e.id) {
_cache[id] = _.template($(e).text());
}
});
return _cache[id](params);
}
return {render: render};
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment