Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
CoffeeScript/Javascript implementation of RFC 6570 for URI-templates
CoffeeScript Makefile
branch: master
Failed to load latest commit information.
src
test Revert "Get uritemplate-test submodule from my fork"
.gitignore improve package and make
.gitmodules
.npmignore add an .npmignore file to counteract .gitignore magic
.travis.yml Add node 0.10 to travis, remove redundant comment
AUTHORS Add AUTHORS file
LICENSE
Makefile tests based on uritemplate-test
README.md Change example code to be valid Javascript
index.pegjs do not allow cut and listMarker together
package.json

README.md

URI Template

Build Status

This is a node.js implementation of the URI template draft standard defined at http://tools.ietf.org/html/rfc6570

Example

var parser = require('uri-template');

var tpl = parser.parse('/{year}/{month}/{day}{?orderBy,direction}');

tpl.expand({ year: 2006, month: 6, day: 6 });
// /2006/6/6

tpl.expand({ year: 2006, month: 6, day: 6, orderBy: 'size' });
// /2006/6/6?orderBy=size

tpl.expand({ year: 2006, month: 6, day: 6, orderBy: 'time', direction: 'asc' });
// /2006/6/6?orderBy=time&direction=asc

var queryTpl = parser.parse('/search{?q,*otherParams}');
queryTpl.expand({ q: 'Bigger office', otherParams: { prefer: "Sterling's office", accept: "Crane's office" }});
// /search?q=Bigger%20office&prefer=Sterling%27s%20office&accept=Crane%27s%20office

For more thorough coverage of the syntax, see test.js or the RFC.

Something went wrong with that request. Please try again.