Hello,
Sorry, but this is going to be long post. I installed this template -
toolkit and want to use it under Apache, BUT there are quite a few
problems. First of all, if i create this handler module for apache can
do it only 'statically' like this [1], but not 'dynamically' like this
[2]. And which version of Apache and Template-toolkit is needed for this
Apache-Template? I tried it with Apache 1.3.9 and 1.3.20 and both times
it said that wrong version of Apache :(. I tried Template-toolkit
versions 2.00, 2.01 and 2.02 still same error.
P.S. Some time ago i got magical error '200 OK' (server encountered
internal error and blah-blah) which it showed after generated page.
Strange...
Files:
1. -------------------------------------------------------------------
sub handler {
my $r = shift;
my $template = Template->new({
OUTPUT => $r,
INCLUDE_PATH => '/hosts/vilts/',});
$r->content_type('text/html');
$r->send_http_header;
my $file = 'index.html'; # or determine dynamically
my $vars = {
message => 'The Cat Sat on the Mat',
};
$template->process($file, $vars, $r) || do {
$r->log_reason($template->error, $r->filename);
return SERVER_ERROR;
};
return OK;
}
2. -----------------------------------------------------------------
sub handler {
my $r = shift;
my $websrc = $r->dir_config('websrc_root')
or return fail($r, SERVER_ERROR,
"'websrc_root' not specified");
my $template = Template->new({
INCLUDE_PATH => "$websrc:$websrc/lib",
PRE_PROCESS => 'config',
OUTPUT => $r, # direct output to Apache request
});
my $params = {
uri => $r->uri,
cgi => CGI->new,
};
# use the path_info to determine which template file to process
my $file = $r->path_info;
$file =~ s[^/][];
$r->content_type('text/html');
$r->send_http_header;
$file = 'index.html';
$template->process($file, $params)
|| return fail($r, SERVER_ERROR, $template->error());
return OK;
}
Rgds,Viljo