[Templates] Bug accessing lists with a single element, introduced between version 2.14 and 2.19
Knut-Olav Hoven
hovenko at linpro.no
Tue Dec 11 14:02:56 GMT 2007
I am using Ubuntu Feisty with libtemplate-perl 2.14-1 on my development
machine and Ubuntu Gutzy with libtemplate-perl 2.19-1 on my production
machine (test now, soon production).
I have an object of type "User" with a "cards()"-method that returns a list
(not an array ref, but a list) of cards, with type "Card", associated with a
user. The user object is accessed through the "user" variable in my
templates.
When the "cards()" method returns a single element I get an error telling me
that there is no method called "Card::size".
This bug only hits in when there is a single card associated with the user,
not with 0 or 2 or more cards.
Example usage in templates:
[% IF user.cards %]
[% user.cards.size %] cards
[% END %]
I have also tried to call it like this without any luck:
[% user.cards.list.size %]
Just for the record, I am using Catalyst and the TTSite view (0.24 vs. 0.25),
but I don't think it has anything to do with this because I call
the "cards()"-method from the templates, regardless of how Catalyst is
setting the "user" variable for use by Template Toolkit.
--
Knut-Olav Hoven
Systemutvikler mob: +47 986 71 700
Linpro AS http://www.linpro.no/
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: This is a digitally signed message part.
Url : http://mail.template-toolkit.org/pipermail/templates/attachments/20071211/2b0c2e27/attachment.pgp
More information about the templates
mailing list