Tmplt.rb

A Ruby gem for interpolating values from a hash or array into a template string.
Usage
Straight-up substitution, nothing more. Here’s a slightly contrived example:
tmpl = "{{ foo }}, {{ bar.baz }}!"
data = {
:foo => "Hello",
:bar => "World",
:baz => {
:qux => Proc.new {|d| "#{d[:bar]}" }
}
}
puts Tmplt.render(tmpl, data) #=> "Hello, World!"
More usage examples are in the tests.
API
Tmplt.render(tmpl, data)
Interpolates values from data into the tmpl string.
tmplis astringwith tags enclosed in double braces. Use a dot-delimited tag to reference nested values indata.datacan be ahashorarray, with arbitrary nesting. If aprocindatais referenced intmpl, it will be invoked, and its return value will be substituted intotmpl. Theproctakes a single argument, namely thedataobject itself.
Installation
Install via RubyGems:
$ gem install tmplt