Unforunately, I can't do "unless defined" because of: (Template/Stash.pm)
sub get {
...
    return defined $result ? $result : $self->undefined($ident, $args);
}

sub undefined {
    my ($self, $ident, $args);
    return '';
}

It seems misleading for undefined to return a null string. 
Why don't just redefine that 'undefined' method in your custom Stash? It is even easier, than redefining 'get':
 
package My::Stash;
use base 'Template::Stash';
use Data::Dumper;
 
sub undefined {
    my ($self, $ident, $args);
    die "Undefined var in TT: (ident,args)=\n", Dumper($ident, $args);
}
 
1;
 
The 'ident' parameter is arrayref containing "identifier" of variable (it compound name).
 
Of course, this method will die even if variable exists but contains undefined value (the Randal's solution will do too). This can be partially avoided by deep filtering of data passed to template, replacing undef values with empty strings. Or you may want to redefine the '_dotop' method - but this is quite complicated.
 

--
Sergey Martynoff

Reply via email to