motion-router

0.3.6 • Public • Published

MotionRouter

A simple client-side router with support for old browsers (Inspired on AngularJS Router and Laravel Router).

Note: The router use hash.

Installation

  • Using bower:

    $ bower install motion-router
  • Using npm:

    $ npm install motion-router

Usage

// New router instance
var router = new MotionRouter();

// Routes
router
  .when('/', function() {
    console.log('Home');
  })
  .when('/one', callback);

// Prefix for routes
router.prefix('/group')
  .when('/one', callback) // #/group/one
  .when('/two', callback); // #/group/two

// Not registered route
router
  .otherwise(function() {
    router.redirect('/'); // Redirection to home
  });

// Run =D
router.run();

Run example

$ npm run example

Package Sidebar

Install

npm i motion-router

Weekly Downloads

0

Version

0.3.6

License

MIT

Last publish

Collaborators

  • aeroxmotion