I am using the Backbone Boilerplate https://github.com/tbranyen/backbone-boilerplate and don't know what's the best way to handle more than one page. I cannot find answer that helps me understand easily. Basically, I am thinking of those options:
- Should each page has a different
config.js? Likeconfig-userpage.js,config-homepage.js...? - Should I have different
router.jsfor different page instead? Likerouter-userpage.jsorrouter-homepage.js,...? - Should I just try a different boilerplate like https://github.com/hbarroso/backbone-boilerplate?
You can definitely try a different boilerplate, but I'm not sure that will help. Multiple pages can be achieved in many different ways.
A good reference example for the Backbone Boilerplate is: http://githubviewer.org/. I have released the entire thing as open source and you can View how basic pages are added there.
You may want to get creative and make a Page model that handles what page you're on and inside of each route set the new page title and which layouts to use.
A very basic, proof-of-concept, implementation inside of
app/router.jsmight look something like this:As you can see, this is an opinionated way of creating "pages" and I'm sure other's have better implementations. At Matchbox, I have a very robust Page model that does breadcrumbs and figures out which navigation buttons to highlight based on the state. You can also create Routers inside your modules to encapsulate functionality and expose the Page model on the app object so that it's available throughout your application.
Hope this helps!