@version 0.1.1
@date 2014-01-14
@stability 2 - Unstable
URI Template –
URI Template RFC 6570 implementation in less than 1kb.
Installation
To use it in the browser, include uri-template-min.js in your site
<script src=uri-template-min.js></script>
In node.js: npm install uri-template-lite
var URI = require("uri-template-lite").URI
Usage
var data = {"domain":"example.com", "user":"fred", "query":"mycelium"}
URI.expand("http://{domain}/~{user}/foo{?query,number}", data)
About error handling
This implementation tries to do a best effort template expansion
and leaves erroneous expressions in the returned URI
instead of throwing errors.
So for example, the incorrect expression
{unclosed will return {unclosed as output.
Browser Support
- For IE6-9 it requires
browser-upgrade-lite
module or other ES5 polyfill.
External links
Licence
Copyright (c) 2014 Lauri Rooden <lauri@rooden.ee>
The MIT License