You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Calling the 'defined' VMethod on an undefined variable raises the "undefined variable" error if template runtime option STRICT is on, so that VMethod is not useful then. It would be more useful if the raising of the "undefined variable" error were suppressed when the 'defined' VMethod is being processed.
Reproduction code:
use warnings;
use strict;
use Template;
my $text = '[% IF foo.defined; "Yes!"; ELSE; "No."; END %]';
my $tt = Template->new({ STRICT => 1 });
$tt->process(\$text) or die $tt->error();
This yields
var.undef error - undefined variable: foo.defined
with Template Toolkit version 2.27. I expected to get No. instead.
A workaround is to use the DEFAULT directive to assign a value to each variable that has none.
The text was updated successfully, but these errors were encountered:
That'd be wonderful. We've had to avoid turning on STRICT because of no way to safely check for a NULL value being returned from a database field, which now means we aren't catching typos in variable names (or even in directives: [% ESLE %] was a fun one).
It would have to have a different name to STRICT, but that isn't a problem.
Calling the 'defined' VMethod on an undefined variable raises the "undefined variable" error if template runtime option STRICT is on, so that VMethod is not useful then. It would be more useful if the raising of the "undefined variable" error were suppressed when the 'defined' VMethod is being processed.
Reproduction code:
This yields
with Template Toolkit version 2.27. I expected to get
No.
instead.A workaround is to use the DEFAULT directive to assign a value to each variable that has none.
The text was updated successfully, but these errors were encountered: