automatically register dom templates

This commit is contained in:
Sam 2014-12-31 13:29:14 +11:00
parent f0ca6150d8
commit 7ff96241a2
1 changed files with 18 additions and 0 deletions

View File

@ -0,0 +1,18 @@
export default {
name: "register-discourse-dom-templates",
before: 'domTemplates',
// a bit smarter than the default one (domTemplates)
// figures out raw vs non-raw automatically
// allows overriding
initialize: function() {
$('script[type="text/x-handlebars"]').each(function(){
var $this = $(this);
var name = $this.attr("name") || $this.data("template-name");
Ember.TEMPLATES[name] = name.match(/\.raw$/) ?
Discourse.EmberCompatHandlebars.compile($this.text()) :
Ember.Handlebars.compile($this.text());
$this.remove();
});
}
};