Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/alveflo/hodor

Minimalistic, simple and easy to use client side routing provider
https://github.com/alveflo/hodor

Last synced: 14 days ago
JSON representation

Minimalistic, simple and easy to use client side routing provider

Awesome Lists containing this project

README

        

hodor.js
======

Minimalistic, simple and easy to use client side routing provider.

#### Usage
```html

```
###### Note
This library utilizes ajax to load referred html pages. So in order to run this library you'll need to be backed up with a web server.
#### API
* `hodor.use(templateEngine)` specify a template engine.
* `hodor.use(path, file)` maps a path against a file
* `hodor.use(path, file, settings)` maps a path against a file and injects settings (used when templating)
* A div with attribute `data-hodor` is needed. This is where the views are injected!

#### Dependencies
* [jQuery](http://jquery.com/)

#### Example setup
```javascript
var app = new hodor();
app.use('/', 'main.htm');
app.use('/about', 'about.htm');
app.use('/contact', 'contact.htm');
```

#### Setup with templating engine
hodor is supporting templating using [{{Mustache}}](https://github.com/janl/mustache.js) as template engine.
```javascript
var settings = {
Foo: 'Foo',
Bar: 'Bar',
};

var app = new hodor();
app.use(Mustache);
app.use('/', 'main.html', settings);
app.use('/about', 'about.html', settings);
app.use('/contact', 'contact.html');
```

#### Full example
```html






Home
About
Contact



var app = new hodor();
app.use('/', 'main.htm');
app.use('/about', 'about.htm');
app.use('/contact', 'contact.htm');

```

#### Licence
The MIT License (MIT)