bartsqueezy / ember-handlebars-brunch

This Brunch plugin adds support for pre-compiling Ember Handlebars templates prior to runtime
MIT License
9 stars 32 forks source link

Add wrapping for AMD modules #14

Closed jas closed 10 years ago

jas commented 10 years ago

This allows use of https://github.com/stefanpenner/ember-jj-abrams-resolver which can load templates from AMD modules instead of Ember.TEMPLATES

When modules.wrapper is set to "amd", Brunch handles adding the module name to the define wrapper function.

Example output after being processed through Brunch. modules.nameCleaner option can be used to remove app/ module prefix.

define("app/templates/index", [], function() {
  return Ember.Handlebars.template(function anonymous(Handlebars,depth0,helpers,partials,data) {
    this.compilerInfo = [4,'>= 1.0.0'];
    helpers = this.merge(helpers, Ember.Handlebars.helpers); data = data || {};
    data.buffer.push("<p>Hello, world!</p>\n");
  });
});

This could be cleaner if we replace modulePrefix with the wrapper function, but I left it for backwards compatibility in case anyone is overriding it.