0.9.0 • Published 6 years ago

flx-router v0.9.0

Weekly downloads
-
License
ISC
Repository
-
Last release
6 years ago

flx-router

Hash-based router for browser apps. Plain JS. No dependencies.

Install

Install with npm

$ npm i flx-router --save-dev

Usage

var BrickRouterFactory = require('flx-router');
BrickRouterFactory({
    routes: 'route1|route2|route3',
    defaultRoute: 'route1', /* route for empty hash */
    errorRoute: 'route1', /* handle your "404":) */
    processor: function(route){
        document.body.setAttribute('data-route-value', route);
        // use some switchable selector to apply further css-based visibility, you can also use classes.
    }
});
// Then you can add simple css rules: #mypage1, #mypage2, #mypage3 {display: none}; [data-route-value=route1] #mypage1 {display: block}

Running tests

Install dev dependencies:

$ npm i -d && npm test

Contributing

Pull requests and stars are always welcome. For bugs and feature requests, please create an issue

Author

Danwin

License

Copyright © 2018 Danwin Licensed under the ISC license.


0.9.0

6 years ago