Thread: [htmltmpl] H::T in mod_perl (probably FAQs)
Brought to you by:
samtregar
From: Emanuele <em...@li...> - 2003-12-10 11:55:53
|
Just some dumb questions by a new HTML::Template-user-wannabe. 1. My goal is to use the 'associate' H::T option in a "pure" mod_perl application (i.e. no CGI code handled by Apache::Registry or Apache::PerlRun.) Does the following work? use Apache::Request; use HTML::Template; sub handler { my $r =3D Apache::Request->instance(shift); my $template =3D HTML::Template->new(filename =3D> 'template.tmpl', associate =3D> $r); # some other code } Apache::Request has a param() method that behaves much like the one from CGI.pm query object, so it should work... But unfortunately the only 'associate' example showed in the H::T pod uses (only) CGI, hence my question. 2. A more general question(s): how do you use H::T in mod_perl? Just CGI code through Apache::Registry or you write your own pure mod_perl(tm) handlers? If so, do you know/use any (simple) mod_perl framework which could be considered the pure mod_perl counterpart of CGI::Application? The only one found so far by me is Apache::PageKit (which does a lot more than CGI::Application really). It seems good, but I'm always scared to find myself sooner or later trapped in a too restrictive environment when using such frameworks. What do you think about PageKit? Thanks a lot. Emanuele (Italy) |
From: Sam T. <sa...@tr...> - 2003-12-10 16:15:40
|
On Wed, 10 Dec 2003, Emanuele wrote: > Apache::Request has a param() method that behaves much like the one from > CGI.pm query object, so it should work... > But unfortunately the only 'associate' example showed in the H::T pod > uses (only) CGI, hence my question. That depends on how similar Apache::Request's param() is to CGI.pm. HTML::Template uses two calls - one with no args to get all param names and the second with one arg to get the value for a parameter. If both those work then everything should be peachy. > A more general question(s): how do you use H::T in mod_perl? I use CGI::Application, either through Apache::Registry or in a custom mod_perl handler depending on the situation. > If so, do you know/use any (simple) mod_perl framework which could be > considered the pure mod_perl counterpart of CGI::Application? Huh? CGI::Application works great in mod_perl! -sam |