Skip to content

Instantly share code, notes, and snippets.

@thomsbg
Last active December 22, 2015 20:29
Show Gist options
  • Star 4 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save thomsbg/6526502 to your computer and use it in GitHub Desktop.
Save thomsbg/6526502 to your computer and use it in GitHub Desktop.
Loop through all the view prototype objects in a namespace, transforming their templateId into a template function.
var compileTemplates = function() {
_.each(App.Views, function(View) {
if (View.prototype.templateId) {
// The templateId references the id of a DOM element containing
// the content of the template
var html = jQuery('#' + View.prototype.templateId).html() || '';
View.prototype.template = _.template(html);
}
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment