in reply to mod_perl and TT2...WITHOUT a calling script?

looking into mod_perl, it should be quite easy to do what I need. i'm going to create a simple mod_perl handler associated with all html documents:
PerlModule My::PerlHandler <Files *.html> SetHandler perl-script PerlHandler My::PerlHandler </Files>
I just need to figure out how to run the actual file requested through a TT2 object in the handler module...any pointers on that? i'm also skimming the mod_perl docs as I type this.

Replies are listed 'Best First'.
Re^2: mod_perl and TT2...WITHOUT a calling script?
by gellyfish (Monsignor) on Jul 10, 2006 at 18:04 UTC

    You could simply have something like the following in your My::PerlHandler :

    use Template; use Apache::Constants qw( :common ); my $tt; sub handler { my ( $request ) = @_; my $file = $request->filename(); $tt ||= Template->new(); my $params = {}; my $out; $tt->process($file, $params, \$out) or do { $request->log_reason( $tt->error ); return SERVER_ERROR; }; + $request->content_type('text/html'); $request->send_http_header; $request->print( $out ); + return OK; }
    But that isn't tested and you may need to flesh it out a bit more.

    /J\

      thanks gellyfish! thats what i needed to know, the $request->filename() method!