Created
March 23, 2012 00:06
-
-
Save borismus/2165681 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
Very good! I take it!
however, there is a little problem:
in 9 lines, miss ; in the end