url-dispatcher
A URL dispatcher. It was inspired by Backbone.Router.
Installation
npm
npm install url-dispatcher --save
// import the modulevar Dispatcher = ;
Bower
bower install url-dispatcher --save
<!-- Or, if you want use on IE8 -->
Manually
git clone git@github.com:haribote/url-dispatcher.git
Or, Download ZIP
And then, copy dest/dispatcher.min.js
to your project.
<!-- Or, if you want use on IE8 -->
Usage
// create instance with the routing map like Backbone.Routervar dispatcher = routes: { return 'root'; } { return '/hoge'; } { return piyo: piyo ; } { return piyo: piyo fuga: fuga ; } { return search: search fuga : fuga bar : bar ; } { return path : path search: search ; } ; // Call run method with URL String dispatcher;/* * ex.) location.href = 'http://www.foobar.com/hoge/1/2' * => { * piyo: 1, * fuga: 2 * } */