[Templates] Apache::Request from Apache::Template
Allen Day
allenday@ucla.edu
Fri, 8 Mar 2002 13:02:12 -0800 (PST)
Thanks for the plugin example. Why though is this a better way to do it?
I liked Andy Wardley's suggestion to have an option in the httpd.conf file
as:
TT2Params uri request
I can't think of a situation where someone would want to access an
Apache::Request object in TT2 when they weren't using Apache::Template, so
this makes more sense.
I do agree that 'request' should not be enabled by default, but it should
be available as a directive option.
-Allen
On Fri, 8 Mar 2002, Vivek Khera wrote:
> >>>>> "MM" == Mark Mills <mark@xodiax.com> writes:
>
> MM> IMHO this is one of the "leave it obscure" features. If you are
> MM> separating content and code, you rarely need the Request
> MM> object. And you are better off calling for it in perl code rather
> MM> than within the template.
>
> You can always pull it in via a plugin, anyway.
>
> PS: do you mind wrapping your lines at a readable length?
>
> Here's my "apr.pm" plugin:
>
> --cut here--
> # Template Toolkit plugin to create an Apache::Request object from a
> # given Apache object, or the default object
>
> package MLM::Plugins::apr;
> use strict;
>
> use vars qw( $VERSION );
> use base qw( Template::Plugin );
> use Apache::Request ();
>
> BEGIN {
> $VERSION = do { my @r=(q$Revision: 1.2 $ =~ /\d+/g); sprintf "%d."."%02d" x $#r, @r };
> }
>
> sub new {
> my $class = shift;
> my $context = shift;
> my $r = shift || Apache->request();
> Apache::Request->instance($r);
> }
>
> 1;
> --cut here--
>
> _______________________________________________
> templates mailing list
> templates@template-toolkit.org
> http://www.template-toolkit.org/mailman/listinfo/templates
>