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
UriTemplate.new
with a UriTemplate.#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.(: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
- Fork it
- Create your feature branch (
git checkout -b my-new-feature
) - Commit your changes (
git commit -am 'Added some feature'
) - Push to the branch (
git push origin my-new-feature
) - Create new Pull Request