CGI-Application-Plugin-TT
view release on metacpan or search on metacpan
Revision history for Perl extension CGI::Application::Plugin::TT.
1.06 2024-11-26 11:07:32-06:00 America/Chicago
- Fix minor documentation typos (Wes Malone, RT#60921)
1.05 Fri Jun 4 14:25:49 EST 2010
- fix dev popup support by html encoding the data sent
to the popup window (patch by Clayton L. Scott)
- fix test failure on windows (patch by Alexandr Ciornii)
1.04 Wed Nov 1 07:08:50 EST 2006
- add TEMPLATE_PRECOMPILE_DIR option which can
automatically compile all your templates on startup
(patch by Michael Peters)
- slightly refactored the default tt_template_name code
- doc fix (Trammell Hudson/Robert Sedlacek)
README
cpanfile
dist.ini
lib/CGI/Application/Plugin/TT.pm
t/01_basic.t
t/02_error.t
t/03_tname.t
t/04_singleton.t
t/05_include_path.t
t/06_callback.t
t/07_devpopup.t
t/08_load_tmpl.t
t/09_precompile_dir.t
t/TestAppBase.pm
t/TestAppBasic.pm
t/TestAppCallback.pm
t/TestAppDevPopup.pm
t/TestAppError.pm
t/TestAppIncludePath.pm
t/TestAppLoadtmpl.pm
t/TestAppPrecompile.pm
lib/CGI/Application/Plugin/TT.pm view on Meta::CPAN
# Add c => $self in as a param for convenient access to sessions and such
$params{c} ||= $self;
$self->tt_obj->process($file, \%params, \$html) || croak $self->tt_obj->error();
# Call tt_post_process hook
$self->tt_post_process(\$html) if $self->can('tt_post_process');
$self->call_hook('tt_post_process', \$html) if $can_call_hook;
_tt_add_devpopup_info($self, $template_name, \%params);
return \$html;
}
##############################################
###
### tt_include_path
###
##############################################
#
lib/CGI/Application/Plugin/TT.pm view on Meta::CPAN
foreach my $super ($class, Class::ISA::super_path($class)) {
no strict 'refs';
return (${$super.'::__TT_OBJECT'}, ${$super.'::__TT_CONFIG'}, $super) if ${$super.'::__TT_OBJECT'};
return (undef, ${$super.'::__TT_CONFIG'}, $super) if ${$super.'::__TT_CONFIG'};
}
return;
}
##############################################
###
### _tt_add_devpopup_info
###
##############################################
#
# This method will look to see if the devpopup
# plugin is being used, and will display all the
# parameters that were passed to the template.
#
sub _tt_add_devpopup_info {
my $self = shift;
my $name = shift;
my $params = shift;
return unless UNIVERSAL::can($self, 'devpopup');
my %params = %$params;
foreach my $key (keys %params) {
if (my $class = Scalar::Util::blessed($params{$key})) {
$params{$key} = "Object:$class";
}
}
require Data::Dumper;
my $dumper = Data::Dumper->new([\%params]);
$dumper->Varname('Params');
$dumper->Indent(2);
my $dump = $dumper->Dump();
# Entity encode the output since it will be displayed on a webpage and we
# want all HTML content rendered as text (borrowed from HTML::Entities)
$dump =~ s/([^\n\r\t !\#\$%\(-;=?-~])/sprintf "&#x%X;", ord($1)/ge;
$self->devpopup->add_report(
title => "TT params for $name",
summary => "All template parameters passed to template $name",
report => qq{<div style="font-size: 80%"><pre>$dump</pre></div>},
);
return;
}
1;
t/07_devpopup.t view on Meta::CPAN
$ENV{CGI_APP_RETURN_ONLY} = 1;
use CGI;
use TestAppDevPopup;
my $t1_obj = TestAppDevPopup->new();
my $t1_output = $t1_obj->run();
like($t1_output, qr/template param\./, 'template parameter');
like($t1_output, qr/<div class="test"><\/div>/, 'HTML tags were encoded as entities');
like($t1_output, qr/TT params for/, 'popup title found');
( run in 0.795 second using v1.01-cache-2.11-cpan-364913b4093 )