I have a data structure defined in a global config file of the form:
[%
data = [
{ 'name' => 'X', 'url' => 'link1' },
{ 'name' => 'Y', 'url' => 'link2' },
{ 'name' => 'Z', 'url' => 'link3' }
]
%]
I want to output the url value for an item with a given name (something
like [% data.(name='Y').url %] to output 'link2', for example). I can
do this with XPath, but is there a way to do this with TT2 an plain data
structures.
At the moment I have:
[% FOREACH data %]
[% IF name == 'Y' %]
[% url %]
[% END %]
[% END %]
My solution works, but I'm wondering if there's a cleaner way of doing
this.
Thanks in advance,
Tom