0.0.4 • Published 12 years ago

earls v0.0.4

Weekly downloads
17
License
-
Repository
github
Last release
12 years ago

Earls

Tiny url library

var earls = require('earls')();

earls.map({
  'products': '/products',
  'products_show': '/products/show/:id'
});

earls.url('products_show', { id: 99 } ); //returns '/products/show/99'

Installation

npm install earls

There is also a earl library in npm so make sure you don't forget the s at the end.

Map

Map will just extend the internal url list (object) with the one you pass it.

earls.map({
  'products': '/products',
  'products_show': '/products/show/:id'
});

Note

You can use map multiple times. It will extend the internal list of urls and not overwrite it.

Register

Mostly map will be enough but incase you like fancy mappings you can register your own mapping method. The method just has to return the same structure as the the default mapping.

earls.register('custom', functionMapper);
earl.custom({}); //Use whatever custom mapping your mapper expects.

A custom mapper that uses functions and works well with Coffee-Script can be found on: earls-function-mapper.

Run tests

Tests use mocha and should.

make test
0.0.4

12 years ago

0.0.3

12 years ago

0.0.2

12 years ago

0.0.1

12 years ago