[Templates] Apache::Template and persistant pnotes across internal_redirects
Perrin Harkins
perrin@elem.com
Sat, 16 Mar 2002 16:24:41 -0500
> The idea was to avoid yet another framework and just use
> Apache::Template. To "pass in my data" I need something
> else, which is the Registry script.
Well, I thought you just said you had a Registry script already, or were
planning to create one. It's trivial to call a template, and I don't
think I would call that amount of code a framework. It could be this
simple:
use vars qw($template);
$template ||= Template->new({
INCLUDE_PATH => "/some/path/from/config"
});
# do your work here and put the results in $data
my $data = {
foo => 'bar'
};
# use path_info here to pick a template if you like
my $file = "/name/of/some/template.html";
$r->content_type('text/html');
$r->send_http_header;
$template->process($file, $data)
|| die $template->error();
However, if you're keen on using Apache::Template, the way you're
supposed to do it is to subclass Template::Service::Apache and override
the params() method to do all of your processing. See the
Apache::Template docs for an example.
- Perrin