Ruby Liquid templating nested hashes
I have a nested hash:
{
:KeyA => {
:KeyB => "hello",
:KeyC => {
:KeyD => "foo",
:KeyE => "bar"
}
}
}
If I pass this ERB, I can do:
<%= config[:KeyA][:KeyC][:KeyD] %>
and get:
foo
However, this does not work with Liquid :(
If I do this:
Liquid::Template.parse(template).render(Hash["config" => myhash ])
I can do:
{{ config }}
and I get pseudo-json on top, but
{{ config[:KeyA] }}
gives nothing: (
Does Liquid support this? If not, what alternatives exist for ERBs that support this, and it is preferable to allow me to configure replacement tags (I cannot use ERB because I run it in an ASP file that contains markup <%)
I had the same problem (importing the yaml object into a hash) and it was impossible to work. Finally, I decided to use erubs. There is life beyond the Liquid, as well as another enngines pattern. You can read a great post at http://www.hokstad.com/mini-reviews-of-19-ruby-template-engines.html