Is it possible to load a Handlebars template via Ajax?

You can register new templates in Ember.TEMPLATES. They will then be available to views.

An excerpt from my code (jQuery Ajax handler):

success: function(data) {
  $(data).filter('script[type="text/x-handlebars"]').each(function() {
    templateName = $(this).attr('data-template-name');
    Ember.TEMPLATES[templateName] = Ember.Handlebars.compile($(this).html());
  });
}

That’s it.

Leave a Comment