Buddy Burden wrote:
The disadvantage is that TT won't apply scalar vmethods to arrays,
hashes, and objects. The subroutine ref is a hassle, but it always
works, no matter what the "ref" of the argument is.
Well, true. You could have a $Template::Stash::LIST_OPS->{'ref'} and a
$Template::Stash::HASH_OPS->{'ref'} also, of course, but that still
doesn't help with the objects.
But then isn't there some way to get a "universal" vmethod? Anyone?
I'm a little busy right now, but I did a quick scan of the code. I
didn't see one. I did see ROOT_OPS, but it behaves like the vars
config I think. All this was a quick 2 minute look, though, so take it
with a grain of salt. I might have time later to check more in depth.
$Template::Stash::ROOT_OPS->{ refg } = sub {
return ref ($_[0]);
};
[% var = ['blah'] %]
[% refg(var) %]
Output: ARRAY
-- Josh
_______________________________________________
templates mailing list
[email protected]
http://lists.template-toolkit.org/mailman/listinfo/templates