Last active
December 22, 2015 20:29
-
-
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.
This file contains hidden or 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
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