UriTemplate

Implements the URI Template draft spec, v7 http://tools.ietf.org/html/draft-gregorio-uritemplate-07

Installation

Add this line to your application's Gemfile:

gem 'uri_template'

And then execute:

$ bundle

Or install it yourself as:

$ gem install uri_template

Usage

  1. UriTemplate.new with a UriTemplate.
  2. #expand the template with a hash of params to be used. Both Strings and Symbols are valid as keys.

Example:

tmpl = UriTemplate.new("http://example.com/search{?q,lang}")
tmpl.expand(:q => ["dogs", "cats"], "lang" => "en_US")
# => "http://example.com/search?q=dogs,cats&lang=en_US"

See the spec for other examples.

Note: Sometimes the spec fails on 1.8 because of hash-ordering. Use 1.9 or an ordered hash library if the order is important to you.

Contributing

  1. Fork it
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Added some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create new Pull Request