GithubHelp home page GithubHelp logo

tpluscode / uri-template Goto Github PK

View Code? Open in Web Editor NEW

This project forked from grncdr/uri-template

0.0 1.0 0.0 54 KB

CoffeeScript/Javascript implementation of RFC 6570 for URI-templates

Home Page: http://tools.ietf.org/html/rfc6570

License: MIT License

Makefile 4.58% CoffeeScript 95.42%

uri-template's Introduction

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.

uri-template's People

Contributors

grncdr avatar andreineculau avatar joeapearson avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.