Howto share subroutes without duplicating them?


Hi Guys,

How can I re-use subroutes in multiple routes…

For example(comments is the subroute I want to re-use/share):

this-route('/posts/edit/', {path: /posts/:post_id/edit }, function() {
this-route('/posts/view', {path: /posts/:post_id/view }, function() {
//The following coments view is showing an empty table..
this-route('/posts/new', function() {

Do I have to dupplicate the route named: ‘comments.js’ or…?


You have to duplicate them indeed.

To make this easier, I usually have both be one-liner, inheriting from a common file. The drawback is they will be two different routes, so they’ll not share their state, should that matter.


Not sure, but maybe you can register your route via registry.

Edit: Got it. :slightly_smiling:

Although, I would go with base comments route and then create comments route as extended base for every top level route.