Closed abraxxa closed 10 years ago
Untested. Does this work?
[% FOREACH row IN [ resultset.all() ] %]...[% END %]
Unfortunately that doesn't work either:
Text::Xslate: Cannot access 'id' (19 is not a container) (/home/ahartmai/perl5/git/NAC-Web-CIS/root/navi.tt:9) at /home/ahartmai/perl5/perlbrew/perls/20/lib/site_perl/5.20.0/Catalyst/Action.pm line 65.
----------------------------------------------------------------------------
[% FOREACH devicegroup IN [ groups.all() ] %]
<li[% IF navlist == devicegroup.id %] id="active"[% END %]><a href="[% c.uri_for_action(c.controller('Device').action_for('list'), [ devicegroup.id ]) %]">[% devicegroup.devicegroupname %]</a></li>
[% END %]
Yeah, I read the docs again, and xslate only allows scalar context on return values. I think you're just going to have to inject a all_arrayref() or something on your Resultset (DBIC allows you to do this, IIRC)
I've tried using Kolon and Metakolon and they also don't allow iterating over arrays returned from a has_many relationship or the all method. I'm giving up on Xslate as long as this feature isn't added as it's too much work for too less benefit. I was hoping to find a template language that is less hassle than TT but Xslate isn't any better at the moment for me.
I didn't find a way to loop an array, not arrayref, when using TTerse syntax with Catalyst::View::Xslate. I'm calling the 'all' method on a DBIx::Class resultset on the Catalyst stash which returns an array of DBIx::Class::Row objects which I want to loop over.