On Mon, Apr 20, 2009 at 09:49:51AM -0700, Sean McAfee wrote:
> On Mon, Apr 20, 2009 at 6:29 AM, Matt S Trout <[email protected]>wrote:
> 
> > On Sun, Apr 19, 2009 at 09:51:42PM -0700, Sean McAfee wrote:
> > > [% FOR a IN as; FOR b IN a.bs; b.cs; "<br>"; END; END %]
> >
> > b.cs here is equivalent to:
> >
> > my $val = [ $b->cs ];
> >
> > not
> >
> > my $val = $b->cs;
> >
> 
> Where does that happen?  I'm pretty intimately familiar with the Template
> Toolkit, having written the Python port, so I know that all method calls in
> a template occur in scalar context, and so "b.cs" in a template should
> indeed translate to "my $val = $b->cs;" on the Perl side.

No, all method calls occur in *list* context. This has been true for as long
as I've been using TT. It was the reason the _rs methods were introduced to
DBIC. You're welcome to write your own code that tests wantarray to verify
this - and unless you do so, I'm not going to believe you that your copy
does the opposite of what everybody else's has for the past several years :P

> So after some finagling, my template now reads:
> 
> [% FOR a IN as; FOR b IN a.bs_rs; !b.cs_rs.defined; "<br>"; END; END %]

a.bs_rs returns a RESULTSET.

FOR b IN a.bs_rs.all will work. You wanted to be able to do .next so I
gave you a resultset. That's not an array.

-- 
      Matt S Trout       Need help with your Catalyst or DBIx::Class project?
   Technical Director                    http://www.shadowcat.co.uk/catalyst/
 Shadowcat Systems Ltd.  Want a managed development or deployment platform?
http://chainsawblues.vox.com/            http://www.shadowcat.co.uk/servers/

_______________________________________________
List: [email protected]
Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
Searchable archive: http://www.mail-archive.com/[email protected]/
Dev site: http://dev.catalyst.perl.org/

Reply via email to