Skip to content
Browse files

update docs

  • Loading branch information...
1 parent 3300574 commit f766de4367c74273bf80588e0aa471dff6964e8c @haggen committed Aug 23, 2012
Showing with 16 additions and 6 deletions.
  1. +16 −6 README.md
View
22 README.md
@@ -6,7 +6,7 @@ Light and flexible URL routing in JavaScript.
You'll need [mocha](https://github.com/visionmedia/mocha) to run the tests.
-Run `npm install -g`. The `-g` flag tells the NPM to install it globally so mocha's binaries goes in `/usr/bin` directory.
+Inside WayJS's directory, run `npm install -g`. The `-g` flag tells the NPM to install the dependencies globally so mocha's binaries goes in `/usr/bin` directory.
Then run `mocha`.
@@ -28,32 +28,42 @@ This will return either the callback or null if no matching route is found.
Way can be used within the browser or with Node.
-Route patterns accepts 3 special syntaxes:
+Also route patterns accepts some special syntax.
+
+## Pattern syntax:
### Named parameters
+Capture anything except forward slashes and save in `way.params`.
+
way.map('/log/:message', function() {
console.log(way.params.message);
});
### Optional groups
+Allow flexible routes.
+
way.map('(/good)/bye', function() {
console.log('Farewell!!');
})
### Splats
+Capture everything, including slashes and save in `way.params.splat`. No more than 1 splat per route.
+
way.map('/goto/*', function() {
console.log('Goto: ', way.params.splat);
});
-They can be combined to create powerful routes.
-Also please note that routes are matched in the order they're registered.
+All the special syntax can be combined to create powerful routes.
+
+Please note that routes are matched in the same order they're mapped.
## Roadmap:
1. Hooks
-2. Better tests
-3. Skipping routes
+2. <del>Better tests</del>
+3. More special syntax
+4. Bypassing routes

0 comments on commit f766de4

Please sign in to comment.
Something went wrong with that request. Please try again.