On Fri, Jul 05, 2002 at 12:12:55PM +0800, Stas Bekman wrote:
> I'd rather see it as:
> + 'sort' => sub { die "Cannot sort a scalar ($_[0])" },
>
> why in the world you will code your templating logic to sort scalars?
I think it comes from the case where a subroutine or method returns
a list of values, rather than a reference to a list. Class::DBI
being an example of such code that you wouldn't necessarily want to
refactor just to keep TT happy.
So if method foo returns @stuff, TT will automatically fold it into
a list if there are > 1 items, otherwise leave it as a scalar item.
So, you might write:
[% myobject.getstuff.sort %]
and then 'sort' is effectively being called against a scalar.
But I think in this case, as Tony has already suggested, the best
approach is this:
[% myobject.getstuff.list.sort %]
A