https://github.com/jsnjack/amy.js
JavaScript routing library
https://github.com/jsnjack/amy.js
Last synced: over 1 year ago
JSON representation
JavaScript routing library
- Host: GitHub
- URL: https://github.com/jsnjack/amy.js
- Owner: jsnjack
- License: mit
- Created: 2015-01-30T17:51:24.000Z (over 11 years ago)
- Default Branch: master
- Last Pushed: 2015-02-08T19:12:53.000Z (over 11 years ago)
- Last Synced: 2025-02-17T18:52:15.965Z (over 1 year ago)
- Language: JavaScript
- Size: 199 KB
- Stars: 0
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
[](https://travis-ci.org/e-shulitsky/amy.js)
[](https://codeclimate.com/github/e-shulitsky/amy.js)
amy.js
============
###What is it
amy.js is a JavaScript routing library
###How to install
amy.js is designed to use in browser. Just add it somewhere in your html file:
```html
```
###How to use
+ Start by adding routes:
```javascript
(function () {
Amy.add("/", function (params) {
some_function();
});
})();
```
+ You can also use capturing groups:
```javascript
Amy.add("/:id/#:type/", function (params) {
...
});
```
+ `params` is the object, that contains capturing groups and query parameters. For the route from section 2 and link `/12/#week/?date=today` `params` object will look something like:
```javascript
params = {
location: "/12/#week/?date=today",
id: 12,
type: "week",
date: "today"
}
```
+ Set up what happens when location is not found in routes:
```javascript
Amy.not_found = function (location) {
do_something();
}
```
+ When you finished with configuration, call init() method:
```javascript
Amy.init();
```
+ To manually run routes check:
```javascript
Amy.run_route("/new/location/");
```