Skip to content

Enome/earls

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

Releases

No releases published

Packages