hsh
Micro client-side router via hashchange
Install
npm install --save hsh
component install andrepolischuk/hsh
API
hsh(path, callback)
Add path
and callback
to routing map.
Each callback takes 2 arguments: context
and next
.
;;;
hsh(callback)
Equivalent to hsh('*', callback)
hsh()
Start hashchange
binding
hsh.start()
Equivalent to hsh()
hsh.show(path)
Calling callback
to defined path
without hash changing
hsh.redirect(path)
Internal redirect to path
, example /#/index
hsh.redirectExternal(path)
External redirect, example /index
hsh.current
Return current path
hsh.prefix
Url prefix, default ''
''
-/#/page
'!'
-/#!/page
Routing
Match to /#/books
;
Match to all paths prefixed with /#/books
;;;
Path *
can be used after all for not found pages
;
Context
path
Current path
params
Path parameters object
Support
- Internet Explorer 7+
- Chrome
- Safari
- Firefox
- Opera
License
MIT