[Templates] [PATCH] Allow undefined values in Stash
Keith Barrette
kbarrette at confex.com
Tue Jul 15 15:30:48 BST 2008
Undefined is a valid return value for a method, but when DEBUG_UNDEF is
set, the current implementation of Template::Stash::_dotop dies with
'foo is undefined' if a method call returns undefined OR if the method
doesn't exist.
The patch separates the nonexistant method and undefined value cases,
and only dies on the nonexistant method case.
Short example:
Object something like this:
package Foo;
sub getUndef {
return undef;
}
If we pass a foo to a template, and do:
[% IF foo.getUndef %]Hello world![% END %]
We would expect that the method call to evaluate to a false value,
rather than die, since it's a valid method.
The patch is only for the perl version of Template::Stash (my C is a bit
rusty). I'll try to have a similar patch for the xs version soon, but I
thought I'd post this first and see what people thought of it.
--
Keith Barrette
The Conference Exchange
More information about the templates
mailing list