As my application grows I feel the need for a more structured router/controller setup. The Marionette docs mention the following:
It is recommended that you divide your controller objects into smaller pieces of related functionality and have multiple routers / controllers, instead of just one giant router and controller.
It would be great if there would be an example for this kind of structure. Suppose I have a website consisting of three sections; People, Media and Articles. Ideally I would like to have routers/controllers for each section. Something like this:
App
-- AppRouter
-- AppController
-- AppLayout
-- PeopleRouter
-- PeopleController
-- PeopleLayout
-- MediaRouter
-- MediaController
-- MediaLayout
-- ArticleRouter
-- ArticleController
-- ArticleLayout
What's very unclear for me is the way how I can let a route ("/people/detail/1") be handled by another router than the AppRouter. It seems that I have to create modules for every section, but does this work nicely with RequireJS? It seems a bit weird to use two different kinds of modules...
It would be great if someone could point me in the right direction, all the examples I found online are a bit confusing to me.
AppRouter
. Marionette Modules are a way to manage namespace and hide data/functions. I'm still trying to work all this out but I think a better directory structure would be as shown in the code for David Sulc's books: github.com/davidsulc/marionette-gentle-introduction/tree/master/… Each app in the apps directory has its ownAppRouter
. – Rhythmist