HashbangJS
A simple and flexible hashbang routing framework
I made this because other frameworks were either too limited in syntax (most of them) or performed badly (the rest of them).
HashbangJS takes a different approach by "precompiling" routes in a format that is both flexible and performs well.
You pay a one time price in performance at the start to gain useful abilities and higher performance while running.
Contact me on github: https://github.com/vanderlee/HashbangJS
Features
- Supports easy text syntax or generatable tree syntax.
- Lets you specify repeating, optional and required elements in a route.
- Supports both divider (#!sort/id/page/123) and assignment (#!sort=id/page=123) or any combination
- Lets you specify randomly ordered elements; if you want #!mail/inbox/private and #!mail/private/inbox can match the same path.
- Lets you specify many other types of elements, and is extendable if you need more.
- Doesn't rely on jQuery, Dojo or any other framework.
- ...but works with all those frameworks and more (jQuery, Dojo, KnockoutJS, Backbone, ExtJS, AngularJS, Ember, etc…).
- Starts automatically, regardless in which order you program the API.
- Handles configurable hashbang prefixes, #, #!, ##, etc… HashBangJS can even handle multiple prefixes at once.
- Unmap and reset paths if you need to change routing.
- Add multiple callbacks to a single route.
- Add callbacks to execute before and after matching a specific route.
- Add callbacks before and after any match; useful for logging and debugging.
- Documented: https://github.com/vanderlee/HashbangJS/blob/master/README.md
- Unittested: test.html
- And I'm using it in a production environment myself!
QUnit test
126 unit testcases at last counting.
Whenever a bug is found, testcases are added to ensure it doesn't ever return.
Click here to run test
Simple examples
Open a console window to read the source and watch the results.
- Path
- Path short
- Path sort
- Path order
- Path all
- Path nothing
- Path 404