Skip to content


Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP


Syntax::TTerse support for looping arrays #124

abraxxa opened this Issue · 4 comments

2 participants


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.


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/ at /home/ahartmai/perl5/perlbrew/perls/20/lib/site_perl/5.20.0/Catalyst/ line 65.
    [% FOREACH devicegroup IN [ groups.all() ] %]
    <li[% IF navlist == %] id="active"[% END %]><a href="[% c.uri_for_action(c.controller('Device').action_for('list'), [ ]) %]">[% 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.

@abraxxa abraxxa closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.