> >Also, I find the Dumper plugin is a great way to debug these kinds
> >of things since you can print out variables at various points to
> >make sure everything is ok.
>
> Is there a way to dump everything that's currently in scope?
Here's one way. This deletes the _PARENT object:
use Data::Dumper;
my $stash = $context->stash->clone();
delete($stash->{_PARENT});
my $d = Data::Dumper->new([$stash], [qw(*Stash)]);
$d->Indent(1);
print $d->Dump;
You could put this in a plugin, or make it a code ref in your call
to process, eg:
use Template;
use Data::Dumper;
my $tt = Template->new();
$tt->process(\*DATA, {
dumpStash => sub {
my $stash = $tt->context->stash->clone();
delete($stash->{_PARENT});
my $d = Data::Dumper->new([$stash], [qw(*Stash)]);
$d->Indent(1);
return $d->Dump;
},
}) || die $tt->error();
__DATA__
[% dumpStash %]
Craig