>>>>> "Geoffrey" == Geoffrey Young <[EMAIL PROTECTED]> writes:
Geoffrey> as far as I know this seems to work ok, and is the only port (official or Geoffrey> non-official) out there Geoffrey> http://www.modperlcookbook.org/~geoff/modules/experimental/Apache-Template-2.00_01.tar.gz I wrote one of my own, very handcrafted without any configuration to speak of. It gets sent through a TT2 phase for [* ... *] during installation. #! perl package Stonehenge::Apache2::Template; use strict; ## warn "reading ", __PACKAGE__; use Apache2::Const qw(NOT_FOUND DECLINED OK SERVER_ERROR); our $tt2 ||= do { require Template::Config; substr(Template::Config->instdir('.'), 0, -2); }; our $tt_parameters ||= { INCLUDE_PATH => ["[* env.PREFIX *]/perl-tt2/templates", "$tt2/templates"], COMPILE_DIR => "[* env.PREFIX *]/perl-tt2/cache/", CACHE_SIZE => 64, POST_CHOMP => 1, RECURSION => 1, EVAL_PERL => 1, LOAD_PERL => 1, ABSOLUTE => 1, RELATIVE => 1, PLUGIN_BASE => ["Stonehenge::Template::Plugin"], PROCESS => "stonehenge/wrapper", }; our $engine; sub handler { my $r = shift; my $filename = $r->filename; ## warn $r->uri, " at ", $r->filename; return NOT_FOUND unless -r $filename; require Template; eval { $engine ||= Template->new(%$tt_parameters) or die "cannot build tt engine"; require CGI; my $cgi = CGI->new($r); my $globals = { uri => $r->uri, request => $r, cgi => $cgi, ## this next one is wrong for multivalued items: params => { map { $_ => scalar $cgi->param($_) } $cgi->param }, }; $engine->process($filename, $globals, \my $o) or die Template->error; $r->print($o); }; if (my $error = $@) { if (eval {$error->isa("Template::Exception")}) { if ($error->type eq "undef") { $error = $error->info; # Perl code called from TT } else { $error = $error->as_string; } } if (ref $error) { # pretty-print coderefs require Data::Dumper; $error = Data::Dumper::Dumper($error); } $r->warn($r->uri, ": tt: ", $error); return SERVER_ERROR; } return OK; } 1; -- Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095 <[email protected]> <URL:http://www.stonehenge.com/merlyn/> Perl/Unix/security consulting, Technical writing, Comedy, etc. etc. See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training! _______________________________________________ templates mailing list [email protected] http://lists.template-toolkit.org/mailman/listinfo/templates
