[Templates] Apache::Request from Apache::Template
Vivek Khera
khera@kcilink.com
Fri, 8 Mar 2002 11:59:07 -0500
>>>>> "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--