Skip to content
Simple routing library that can be use on the server or in the browser
JavaScript HTML
Find file
Latest commit bcc2c81 @jcubic Merge pull request #1 from sonnyp/patch-1
Fix doc typo
Failed to load latest commit information.
spec Fix test for last fix
.gitignore all files
README.md Fix doc typo
SpecRunner.html remove jquery
bower.json ignore tests
route.js Fix escape_re function

README.md

route.js

Very small and simple routing library that can be use on the server or in the browser. It use dependency injection to inject arguments to your function.

It contain only a router so it can be use anywhere. It's only the API so you need to write your own code that will execute when ever you want (like on hashchange or using HTML5 History API).

Usage

var router = new route();

router.match('/foo/bar/{{id}}/{{name}}', function(name, id) {
    // name and id will be in different order
    // names in url need to match names in function
    console.log(name + ' ' + id);
});

router.exec(location.hash.replace(/^#/, ''));

License

Copyright (C) 2014 Jakub Jankiewicz <http://jcubic.pl>
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>

This is free software; you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.

Something went wrong with that request. Please try again.