Re: Iterate over keys value

Gert van Oss <[email protected]> Wed, 04 Feb 2015 13:41:01 -0500
Newsgroups gmane.comp.lang.perl.modules.template-toolkit
Message-ID <[email protected]>
Maybe something like this gets you there..?

[% FOREACH country IN all_content.keys.sort %]
    <h3>[% country %]</h3>
      [% FOREACH line IN all_content.$country %]
	    [% line.name %]<br />
	    [% line.street %]<br />
	    [% line.city %]<br />
      [% END %]
    [% END %]


> On 04 Feb 2015, at 12:13, thorshand <[email protected]> wrote:
> 
> Hi,
> 
> Is it possible to iterate over a key value, like : 
> 
> <% foreach c in comment({id_table = 'Blog'}) %>
>    <% c.date %> <% c.id %>
> <% end %>
> 
> comment is a resulset of dbix search with columns : id, id_table, name, date, ... 
> I would like to make one dbi request (don't include where clause in resultset) to do this after :
> 
> <% foreach table in ('Blog', 'Wiki' ...) %>
>    <% foreach c in comment({id_table = table}) %>
>       <% c.date %> <% c.id %>
>    <% end %>
> <% end %>
> 
> Thanks
> _______________________________________________
> templates mailing list
> [email protected]
> http://mail.template-toolkit.org/mailman/listinfo/templates