My Ember.Router grows and grows and it looks like it's gonna maintain more than thirty URL routes soon. Now, a lot of these routes do the same thing, for example connecting a header outlet (in maybe 80% of all the cases).
Is there an Ember.js-way to avoid these redundancies? Or should I just move the duplicate parts into a function and call that?
Update
As you can see, there are three different routes (articles, posts and users). Two of them connect the header outlet, while the third one doesn't. Now Imagine there would be 25 routes which connect the header outlet and 5 which don't. How can I avoid these duplications?
App.Router = Em.Router.extend({
root: Em.Route.extend({
articles: Em.Route.extend({
route: "/articles",
connectOutlets: function(router) {
router.get("applicationController").connectOutlet("header", "header");
router.get("applicationController").connectOutlet(articles, App.Article.find());
}
}),
posts: Em.Route.extend({
route: "/posts",
connectOutlets: function(router) {
router.get("applicationController").connectOutlet("header", "header");
router.get("applicationController").connectOutlet("posts", App.Post.find());
}
}),
users: Em.Route.extend({
route: "/users",
connectOutlets: function(router) {
// Don't connect the header here!
router.get("applicationController").connectOutlet("users", App.User.find());
}
})
})
});