New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Optional parameters #3
Comments
Thank you for the suggestion, but this feature will not be implemented in PathJS. PathJS is meant to closely mimic the Rails router, which has specifically defined routes per action. After thinking on the issue, I've come up with a potential solution to your "default value" issue:
This solution allows you to set defaults for any particular route, and access a route without having any data beforehand by using that default. Do you think this solution is a reasonable middle ground to keeping the strict "one route, one action" style of PathJS while providing you access to convenient defaults? |
Actually, as of Rails 3 you can do optional parameters in your routes.
Sends both of the below routes to the same controller. I guess I just think that the below routes: Looks more RESTful than: But it really only applies in certain situations. One thing I should have mentioned is that in my original example, adding the '?' is what makes it optional, otherwise if the '?' was not added to the match, it would require that param to exist to match that route. So I think everyone wins in that scenario. Either way, I'm going to continue to use your lib, I think it's excellent. I just may have to duplicate a little more code. Thanks! |
This feature is under development. |
This feature was added as part of commit |
This would help DRY out some code so that someone doesn't have to duplicate route maps.
For example ( this is how ExpressJS does it on the server side ):
I would happily fork it and submit the changes to make this work, however my javascript-fu is weak. Looking at the code, I couldn't tell how easily this could be accomplished. So this is just a feature request.
The text was updated successfully, but these errors were encountered: