sub tt_pre_process {
my $self = shift;
my $file = shift;
my $vars = shift;
$vars->{c} ||= $self;
return;
}
That will automatically put your CGIApp object into the template
parameters for every template that is processed. That way you have
access to the query object, and some other convenience methods from
within your templates. For example, if you have the users name in the
session, and you used the CGI::Application::Plugin::Session module,
you could add [% c.session.param( 'username' ) %] to display the
username in the template.
I do something like this, but I run my CGI::App driver under
Apache::Registry, so I had to:
sub cgiapp_postrun {
my $self = shift;
$self->tt_params( c => undef ); # remove circular reference
}
To get the reference count of $self's referent to 0. The circular reference
manifested itself in my code by not flushing the session after a request.
Todd W.
_______________________________________________
templates mailing list
[email protected]
http://lists.template-toolkit.org/mailman/listinfo/templates