weslleyaraujo / Estrada
Licence: mit
Very lightweight javascript router manager, no dependencies at all.
Stars: ✭ 10
Programming Languages
javascript
184084 projects - #8 most used programming language
Estrada
Estrada is a lightwell router manager crafted with no dependencies and based to work on major browsers (IE9+).
It was inspired by Backbone Router.
Basic Usage
You can install estrada using bower:
bower install estrada
In order to start using Estrada you should include the main script into your page as:
<script src="estrada.js" ></script>
Then you can register your routes like:
Estrada.register({
routes: {
'': 'example'
},
example: function () {
// you callback for '' route
console.log('yay!');
}
});
Estrada.start();
You can also register routes with multiple parameters like:
Estrada.register({
routes: {
'/user/:id': 'user',
'/example/:id/foo/:slug': 'multiple'
},
user: function (id) {
// you callback for '/user/:id' route
console.log('thats my callback for /user/:id', id);
},
multiple: function (id, slug) {
// you callback for '/example/:id/foo/:slug' route
console.log('thats my callback for /example/:id/foo/:slug', id, slug);
}
});
Estrada.start();
Documentation
Estrada.register ({ routes: {}, ...callbacks })
Register routes and each callback.
-
{ routes: {} }
(object): the routes object -
{ ..callbacks }
(function): your routes callbacks
Usage:
Estrada.register({
routes: {
'/example': 'exampleCallback'
},
exampleCallback: function () {
// callback
}
})
Estrada.start ()
Starts the routes system.
Usage:
Estrada.start();
Estrada.navigate ()
Navigate into a url
Usage:
Estrada.navigate('/example');
Release History
- v0.1.0 - First release
- v0.1.1 - Creating release grunt task
- v0.1.2 - Fix bug when route was triggered by undefined param
- v0.1.3 - Adding navigate method
License
Note that the project description data, including the texts, logos, images, and/or trademarks,
for each open source project belongs to its rightful owner.
If you wish to add or remove any projects, please contact us at [email protected].