https://github.com/anthonyshort/static-router
Simple router to match URLs and fire callbacks without pushState.
https://github.com/anthonyshort/static-router
Last synced: 30 days ago
JSON representation
Simple router to match URLs and fire callbacks without pushState.
- Host: GitHub
- URL: https://github.com/anthonyshort/static-router
- Owner: anthonyshort
- Created: 2013-01-21T20:21:43.000Z (over 12 years ago)
- Default Branch: master
- Last Pushed: 2013-01-24T10:03:08.000Z (over 12 years ago)
- Last Synced: 2025-04-14T02:05:20.293Z (30 days ago)
- Language: JavaScript
- Homepage:
- Size: 164 KB
- Stars: 7
- Watchers: 1
- Forks: 0
- Open Issues: 3
-
Metadata Files:
- Readme: Readme.md
- Changelog: History.md
Awesome Lists containing this project
README
# static-router
Simple router to match URLs and fire callbacks without pushState. Designed for simple sites who want to structure code using routes but don't need pushState. Borrowed heavily from Backbone's router object. It's a lot better than just throwing everything in a global scope.
## Installation
$ component install anthonyshort/static-router
## API
var Router = require('static-router');
var router = new Router();
router.route('/welcome', function(){
alert('Welcome page!');
});
router.route('/profile/:user', function(user){
console.log(user);
});
router.route('/profile/*', function(){
console.log('match anything after profile!');
});## License
MIT