lib-route-generator
v0.1.1
Published
generate client side routes from parameter lists
Downloads
12
Readme
lib-route-generator
install
npm install --save lib-route-generator
usage
var Generator = require('lib-route-generator')();
var generator = Generator.NewFromString('/users/:name');
generator.format({name: 'bob'});
// /users/bob
a more compelx route
var generator = Generator.NewFromString('/find/:category/:query');
generator.format({category: 'shoes', query: 'leather+black'}, {order: 'desc', limit: 100});
// /find/shoes/leather+black?order=desc&limit=100
errors
var Generator = require('lib-route-generator')();
var generator = Generator.NewFromString('/users/:name');
generator.format({});
// Error: Parameters Missing Key: name
see also
- lib-route-matcher client side library for generating routes from a matcher