Hi,
for better or worse I seem to use Class::MethodMaker for quite a bit of my OO
programming and when combined with TT I've experienced oddness thats causing
me trouble.
As you may well know Class::MehtodMaker has a 'list' type method that such
that it creates foo, foo_push, foo_pop, foo_count etc accessor methods,
$self->foo returning a list of all the items pushed onto the list.
So .. in my code I do:
$self->foo_push({name => 'beer' , price=>'2 quid'});
$self->foo_push({name => 'pie' , price=>'mmmm'});
and in TT:
[% FOREACH item = pricelist.foo %]
its a [% item.name %] and it costs [% item.price %]
[% END %]
which works just fine so long as there are 2 or more items in the list ... if
there is just one item it TT seems to assume that the anonymous hash is
infact a list of 2 items 'pie' and 'mmmm', the lopp iterates twice, and
ofcourse item.price etc return undef.
my temporary solutions is to do [% WHILE (item = pricelist.foo_pop ) %] which
works, but of course leaves the list empty when its finished, which is not
what I want.
Any suggestions as to how to get it to DWIM gratefully rx
--
Robin Szemeti
_______________________________________________
templates mailing list
[EMAIL PROTECTED]
http://www.template-toolkit.org/mailman/listinfo/templates