I would like to share templates, controllers, and routes between different parent routes. For example, I’d like to use the same leaf templates (billing.hbs and subscriptions.hbs) under admin.user.billing and user.billing.
How about using router#render to explicitly assign the template / controller ?
Ref: Route - 4.6 - Ember API Documentation
I think route can not be shared in this way though.
I am already using components, but I don’t see how using components can alleviate the need for two templates and two routers for every endpoint I want to share between the admin and user routes.
export default Ember.Route.extend({
// the only tricky part here is determining what param to pass to modelFor
// (admin.user or user) when we need the parent's model
});
routes/admin/user/foo.js
import UserFoo from '../../user/foo';
export default UserFoo.extend({
templateName: 'user/foo',
});
I still need one extra route file per route, but everything else is shared. I added a service (Context) that is aware of whether we’re in the user or admin context based on whether we’re in the admin.user or user route, and a custom link-to helper that uses the correct route when creating links.
The admin/user/:user_id route & template behave differently than the user route & template. They pull a different user (one from session, one from the url path) and display very different information. It’s really only their outlets that are similar.