[Catalyst] Template::Toolkit + Empty Lists
Nigel Metheringham
Nigel.Metheringham at dev.intechnology.co.uk
Tue Aug 1 09:58:57 CEST 2006
On Mon, 2006-07-31 at 22:37 -0700, Mark Blythe wrote:
> This is slightly off-topic, but since I'm running into this problem
> while using Catalyst, I'm hoping that others on the list may have
> already solved it.
>
> I was writing a simple template today, using TT + DBIC. I had an
> object and was exercising a has_many relationship. I simply wanted to
> see if any rows had been returned. It seemed simple enough:
>
> [% SET children = parent.children %]
> [% IF children.list.size %]
> ...
> [% END %]
How about
[% SET children = [ parent.children ] %]
or
[% SET children = [ parent.children.all ] %]
[I'm not sure how the .all - which forces it to return an array of rows
- plays with a prefetch in the original query... which would seem like a
good idea if you are definitely going to use that relationship]
Nigel.
--
[ Nigel Metheringham Nigel.Metheringham at InTechnology.co.uk ]
[ - Comments in this message are my own and not ITO opinion/policy - ]
More information about the Catalyst
mailing list