Randal,

Thanks for the help.  With a bit of fanangling, I was able to get it working.  Here's my changes:

In my main program:  I had to "use My::Stash" AFTER "use Template".  Before had no effect.

    package My::Stash;
    use base qw(Template::Stash);

    sub get {
      my $self = shift;
      my $value = $self->SUPER::get(@_); # get original value
      die "Missing parameter '$_[0]' in template" if $value eq '' || ! defined $value;
      return $value;
    }

    $Template::Config::STASH = __PACKAGE__; # use me, not that

    1;



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.

Once again, thanks for your help!
-Tommy.

Randal L. Schwartz wrote:
    package My::Stash;
    use base qw(Template::Stash);

    sub get {
      my $self = shift;
      my $value = $self->SUPER::get(@_); # get original value
      die "stash got @_ as undef" unless $value eq '';
      return $value;
    }

    $Template::Config::STASH = __PACKAGE__; # use me, not that

    1;
"Thomas" == Thomas Falgout <[EMAIL PROTECTED]> writes:
            

Thomas> Instead of substituting a blank, how can I get $template->process() to
Thomas> give me an error if there's any variables that aren't defined? I know
Thomas> that I shouldn't have any missing variables, but I'm developing the
Thomas> interface and someone else is developing the templates.  Sometimes
Thomas> there's missing info.  I'd like to be able to find out when I've
Thomas> missed something, rather than Templates blindly putting in blank vars.

You might be able to subclass Template::Stash and override ->get so that it
yells if an undef value is returned.

    package My::Stash;
    use base qw(Template::Stash);

    sub get {
      my $self = shift;
      my $value = SUPER::get(@_); # get original value
      die "stash got @_ as undef" unless defined $value;
      return $value;
    }

    $Template::Config::STASH = __PACKAGE__; # use me, not that

    1;

Then say "use My::Stash" before "use Template".

  
_______________________________________________ templates mailing list [email protected] http://lists.template-toolkit.org/mailman/listinfo/templates

Reply via email to