package Simple; use strict; use lib '/var/www/mod_perl/build/TT2_wip/lib'; use CGI::Builder qw/ CGI::Builder::TT2 /; use Data::Dumper; sub PH_index { my ($self) = @_; # # Use your PH handler to calculate values and store them for use # by your templates. # $self->tt_vars(page_title => "Simple Example"); $self->tt_vars(content => $self->myContent); # # If you wish, you can set a custom template in your PH handler, # instead of using the default. # # $self->tt_template('my_special_template.tt2'); # # If you have templates stored in other places, you may want to # change your include path. # # $self->tt_new_args(INCLUDE_PATH => ['/my/app/templates', '/usr/local/tt2']); # # If, for some reason, you want to disable the template engine for # this request, just set the page content to something else. # # $self->page_content("Not a Template!"); }#END sub PH_index sub myContent { my ($self, $content) = @_; $content .= sprintf("\n

Page Name defaults to (%s)

", $self->page_name); $content .= sprintf("\n

Page Suffix defaults to (%s)

", $self->page_suffix); $content .= sprintf("\n

Template defaults to page_name + page_suffix (%s)

", $self->tt_template); $content .= sprintf("\n

Page Path defaults to (%s)

", $self->page_path); my $d = Data::Dumper->new( [scalar($self->tt_new_args)], ['tt_new_args'] ); $content .= sprintf("\n

Template new args by default will contain only one value, it will set the INCLUDE_PATH = page_path. You may override this if your templates are in a different place (or in multiple places).

%s

", $d->Dump); return $content; } sub PH_AUTOLOAD { my ($self) = @_; $self->tt_vars(page_title => "PH_AUTOLOAD"); $self->tt_vars(content => " This content will not be seen, because PH_AUTOLOAD is only called when the page_content is empty, but C::B::TT2 sets the page_content to its own special printing routine. "); }#END sub PH_AUTOLOAD "Copyright 2004 by Vincent Veselosky [[http://www.control-escape.com]]";