layout | title | module_path |
---|---|---|
default |
Chaplin.Route |
src/chaplin/lib/route.coffee |
The Chaplin Route
is used by Chaplin.Router
to generate regular expressions and extract pramaters from a given pattern.
- match: the parameter with the colon
:user
- paramName: the parameter with the colon stripped
user
- path: a relative path to check against
- criteria:
- String. Will compare this.name with it.
- Object. Will compare this[field] with each object[field].
Returns Boolean
.
- params:
- Array. List of params from which URL will be generated.
- Object. Named params from which URL will be generated.
Returns route url if all params were cool and false
otherwise.
- path: the matched path
- options: an optional object
- path: the matched URL path
- options: an optional object
- path: the URL path
- path: the URL path
A new instance of Chaplin.Route
is created for each route in the routes file of your application. This occurs when the match method of Chaplin.Router
is called. The actual routes file should be in the root of your project along with your main application bootstrapper file.
The routes file is basically a module that returns an anonymous function in which the match method is passed in as an argument.