I propose adding a DUMP directive. I've had this in CGI::Ex::Template
since May of last year. I have found it almost invaluble. I am
willing to write all of the code necessary to have it in TT2. It
works something similar to the following:
Assuming:
my $file = <<"HERE";
Some text:
[% DUMP a %]
[% DUMP [b, c, 1+2] %]
[% DUMP '' %]
[% DUMP %]
HERE
CGI::Ex::Template->new->process(\$file, {
a => "A string",
b => {key1 => 'val1'},
c => [qw(foo bar baz)],
_d => "Something hidden",
e => sub { die },
});
That would print the following:
Some text:
DUMP: File "input text" line 2
a = 'A string';
DUMP: File "input text" line 3
[b, c, 1+2] = [
{
'key1' => 'val1'
},
[
'foo',
'bar',
'baz'
],
3
];
DUMP: File "input text" line 4
'' = '';
DUMP: File "input text" line 5
EntireStash = {
'a' => 'A string',
'b' => {
'key1' => 'val1'
},
'c' => [
'foo',
'bar',
'baz'
],
'e' => sub { "DUMMY" },
'global' => {}
};
(Actually the DUMP headers are missing when ran from the commandline.
They are there when used from a CGI - they are there on the commandline
in the 2.11 release).
I have found this very valuable for determining if I am receiving
the items I though I was. It is also very useful to get the
filename (relative to INCLUDE_PATH) and line number that the
directive was used at.
If other people are interested - and maybe if not, I'll whip up some
patches that will make those options work on Template Toolkit 2.
Paul
_______________________________________________
templates mailing list
[email protected]
http://lists.template-toolkit.org/mailman/listinfo/templates