Re: [Templates] Apache::Template & plugin path problems

[prev] [thread] [next] [Date index for 2004/05/12]

From: Dave Cash
Subject: Re: [Templates] Apache::Template & plugin path problems
Date: 17:32 on 12 May 2004
On Wed, 12 May 2004, Simon Wilcox wrote:

> My file structure looks like this:
>
> /var/www/site/html (html docs)
> /var/www/site/lib  (TT templates)
> /var/www/site/data (xml files)
>
> In my template I have
>
> [% USE XML::Simple( 'data/menu.xml' ) %]
>
> This works fine in ttree when run from /var/www/site but blows up when
> using Apache::Template (which we often do for rapid development, and burn
> using ttree for publication).
>
> I've set an include path using TT2IncludePath so that it should look
> relative to /var/www/site but I get an error:
>
> [Wed May 12 17:56:54 2004] [error] access to
> /var/www/site/html/index.html failed for 192.168.112.82, reason:
> plugin error - File does not exist: data/menu.xml at
> /usr/local/lib/perl5/site_perl/5.8.2/i686-linux/Template/Plugin/XML/Simple.pm
> line 47
>
> Any ideas what I'm doing wrong here ?

It looks to me like Template::Plugin::XML::Simple just passes the
'data/menu.xml' value to XML::Simple::XMLin, which is agnostic of TT
INCLUDE_PATH or TT2IncludePath types of things.  I think it works
via ttree because the the command-line Perl interpreter has a
"working directory" concept, whereas mod_perl does not.

One solution would be to do this:

 [% USE XML::Simple( '/var/www/site/data/menu.xml' ) %]

But that is rather ugly.  Another solution would be to set a
variable in a PRE_PROCESS'ed template called something like
'base_path', and then do this:

 [% USE XML::Simple( "${base_path}/data/menu.xml" ) %]

I hope that helps.

Dave

/L\_/E\_/A\_/R\_/N\_/T\_/E\_/A\_/C\_/H\_/L\_/E\_/A\_/R\_/N\
Dave Cash                              Power to the People!
Frolicking in Fields of Garlic               Right On-Line!
dave@xxxxx.xxx                                  Dig it all.

_______________________________________________
templates mailing list
templates@xxxxxxxxxxxxxxxx.xxx
http://lists.template-toolkit.org/mailman/listinfo/templates

Re: [Templates] Apache::Template & plugin path problems
darren chamberlain 17:08 on 12 May 2004

Re: [Templates] Apache::Template & plugin path problems
Dave Cash 17:32 on 12 May 2004

Generated at 08:55 on 15 Mar 2005 by mariachi v0.52