I find that when I separate my presentation and code with Template Toolkit, I often find that I've goofed in trying to access my data correctly within the template. This little snippet generates a nice, pretty-printed output directly to the template.
To use this, I place the following line of code right before the closing body tag in the template:
<pre>[% dump %]</pre>
use strict; use CGI; use Template; use constant DEBUGGING => 1; $|++; my $query = CGI::->new; my $template = Template->new( { INCLUDE_PATH => '..\templates', ABSOLUTE => 1 } ); my $data = { one => 1, two => 'foo', bar => [qw/ baz qux Ovid/] }; if ( DEBUGGING ) { require Data::Dumper; require HTML::Entities; $data->{ dump } = HTML::Entities::encode_entities( Data::Dumper::Dumper( $data ) + ); } print $query->header; $template->process( 'some.tmpl', $data ) or dienice $template->error();
In reply to Debugging Template Toolkit by Ovid
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |