Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

sub-routes? #62

Closed
mxriverlynn opened this issue Mar 27, 2012 · 8 comments
Closed

sub-routes? #62

mxriverlynn opened this issue Mar 27, 2012 · 8 comments

Comments

@mxriverlynn
Copy link
Member

a client showed me some code to do sub-routes... routes that only match below a specified root. instead of:

someRoot/someResource/:id

we could do

someResource/:id

and specify a root: 'someRoot' in the configuration or initializer options for the router.

thinking about this for Marionette's app router.

@sberryman
Copy link

+1

@geekdave
Copy link

geekdave commented Apr 9, 2012

Just wrote a blog on this topic:
http://www.geekdave.com/?p=13

Also created a Github repo for a Backbone.Subroute plugin:
https://github.com/ModelN/backbone.subroute

Feedback welcome! Still have to write some tests for this plugin, but seems to be working well for me so far.

@chancancode
Copy link
Contributor

+1 for this. I was thinking something that's along the line of @geekdave's approach.

@mxriverlynn
Copy link
Member Author

i'd love to see someone send in a pull request for this.

every time i think i need it, i find that there's something else in my application that isn't set up right, and I after I fix that I realize that I don't need sub-routes.

i still think there's something worthwhile here, but the apps that i've been building so far are rather flat in terms of routing needs.

@chancancode
Copy link
Contributor

I found this in the documentation:

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.

I suppose if you split things up in to multiple routers by subroutes, you could achieve similar effect.

@mxriverlynn
Copy link
Member Author

@chancancode that's how i approach routers and modules, which is a big reason why i don't need sub-routes. my routers tend to be so small and focused that it's just not an issue for me to add the root folder to the paths. sure, it would be slightly less to type in some cases

again - if anyone wants to send in a pull request :) otherwise, i think i'm going to close this one soon

@mxriverlynn
Copy link
Member Author

closing this as it doesn't seem to be a pressing issue for anyone (myself included). i'd recommend using geekdave's solution

@samccone
Copy link
Member

see #1177 for a unified discussion about the router.

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants