Ember-Rails and namespaced templates
Asked Answered
H

1

9

I have a Rails app that is namespaced into three sections (almost 3 apps that share models). I would like for each namespaced section to have it's own Ember app. These apps are never loaded in the same layout so don't have to know anything about each other. In fact I would like to keep the code as separate as possible for when the app can eventually be really split up.

I am trying to do this using the ember-rails gem.

Basically it is like this question: How can I specify an alternative directory for my HandlebarsJS templates with the ember-rails gem?

And the answer there works, but I'm pretty sure using templates_root limits me to just one namespace. So I couldn't also have an admin.js and admin/templates namespace as well as a customer.js and customer/templates namespace.

So does anyone know if ember-rails will support multiple namespaced Ember apps and render multiple template roots as a result?

Thanks!

Hectare answered 7/4, 2013 at 6:19 Comment(1)
Collecting info no this Github pull request (github.com/emberjs/ember-rails/pull/111), will add final answer here once I get it.Hectare
G
12

As posted here you can have namespace templates by adding a custom resolver to each app.

App1 = Ember.Application.create({
  Resolver: Ember.DefaultResolver.extend({
    resolveTemplate: function(parsedName) {
      parsedName.fullNameWithoutType = "app1/" + parsedName.fullNameWithoutType;
      return this._super(parsedName);
    }
  })
});

App2 = Ember.Application.create({
  Resolver: Ember.DefaultResolver.extend({
    resolveTemplate: function(parsedName) {
      parsedName.fullNameWithoutType = "app2/" + parsedName.fullNameWithoutType;
      return this._super(parsedName);
    }
  })
});

App3 = Ember.Application.create({
  Resolver: Ember.DefaultResolver.extend({
    resolveTemplate: function(parsedName) {
      parsedName.fullNameWithoutType = "app3/" + parsedName.fullNameWithoutType;
      return this._super(parsedName);
    }
  })
});
Geologize answered 14/8, 2013 at 6:19 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.