route

0.2.5 • Public • Published

route

Basic routing:

function foo(year, month, day, id) {
    // ...
};

function bar(first, middle, last) {
    // ...
};

function baz(optional) {
    // ...
};

$.route.add({
    'foo/:year/:month/:day/:id': foo,  // Regular arguments capture a single path part
    'bar/:first/*middle/:middle': bar  // Splat arguments capture any number of path parts
    'baz[/:optional]': baz  		   // Brackets indicate optional path components
});

$.route.run(document.location.pathname);

Usage with Ender

After you install Ender, include route in your package:

ender add route

Package Sidebar

Install

npm i route

Weekly Downloads

273

Version

0.2.5

License

none

Last publish

Collaborators

  • amccollum