-
-
Save zoghal/2783361 to your computer and use it in GitHub Desktop.
dynamic template loading
This file contains 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
/* | |
* Loads a handlebars.js template at a given URL. Takes an optional name, in which case, | |
* the template is added and is reference-able via templateName. | |
*/ | |
function loadTemplate(url, name, callback) { | |
var contents = $.get(url, function(templateText) { | |
var compiledTemplate = Ember.Handlebars.compile(templateText); | |
if (name) { | |
Ember.TEMPLATES[name] = compiledTemplate | |
} else { | |
Ember.View.create({ template: compiledTemplate }).append(); | |
} | |
if (callback) { | |
callback(); | |
} | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment