Paul Seamons wrote:
> Objects returning undef is fine (2.19 TT):
>
> perl -e 'package A; sub foo {}; $a = bless {}, A; use Template;
> Template->new->process(\qq{([% a.foo %])\n},{a=>$a})'
>
> ()
>
> Objects returning a list of (undef, "true value") is not fine which is
> even more obscure:
>
> perl -e 'package A; sub foo {(undef,"ouch")}; $a = bless {}, A; use
> Template; Template->new->process(\qq{([% TRY; a.foo ; CATCH; e; END
> %])\n},{a=>$a})'
>
> (undef error - ouch at input text line 1.
>
> )
>
> I'd be interested to see what is getting returned. I'm wondering if in
> the original post if foo is an object blessed into the Foo namespace -
> I'm guessing it isn't.
>
> Paul Seamons
>
Here's an example of what I'm talking about:
perl -e 'package MyPackage; sub returnundef { return undef}; $object =
bless {}, MyPackage; use Template; Template->new->process(\qq{([%
object.returnundef %]) ([% object.nonexistantmethod %])},
{object=>$object});'
The issue isn't that undef is not allowed, it's that I can call
nonexistent methods on an object, and get no error. If I turn on
DEBUG_UNDEF, which would throw an error on
[% object.nonexistantmethod %]
I also get an error on
[% object.returnundef %]
TT doesn't differentiate between an existing method that returns undef,
and a nonexistent method.
--
Keith Barrette
The Conference Exchange
_______________________________________________
templates mailing list
[email protected]
http://mail.template-toolkit.org/mailman/listinfo/templates