package Sledge::Plugin::DebugTemplate; use strict; use vars qw($VERSION); $VERSION = '0.01'; sub import { my $class = shift; my $pkg = caller; no strict 'refs'; $pkg->register_hook( AFTER_DISPATCH => sub { my $self = shift; return unless $self->debug_level; if($self->r->param('debug_template')){ my $text = $self->r->param('debug_template'); my %config = %{$self->tmpl->{_options}}; my $template = Template->new(\%config); my $output; $template->process(\$text, $self->tmpl->{_params}, \$output); $self->r->content_type('text/html; charset=utf-8'); $self->r->header_out('Content-Length' => length($output)); $self->r->send_http_header; $self->r->print($output); $self->finished(1); } } ); } 1; __END__