dss <[EMAIL PROTECTED]> said something to this effect on 11/14/2001:
> --- darren chamberlain <[EMAIL PROTECTED]> 
> > 
> >       use Template;
> >       use File::Find;
> >       my $t = Template->new(
> >                 INCLUDE_DIR => "/web/templates",
                    INCLUDE_PATH => "/web/templates", # My typo, not yours!
> >                 COMPILE_DIR => "/var/ttcache",
> >                 OUTPUT      => "/dev/null",
> >               );
> > 
> >       sub process {
> >         $t->process($_, { }) or warn $t->error;
> >       }
> > 
> >       find(\&process, "/web/htdocs");
> > 
> >     These templates will now be precompiled in
> >     /var/ttcache/web/templates, which is where the
> > Template::Provider
> >     objects will look for them at runtime.
> 
> darren,
> 
> Thank you *very* much for this info. I am thankful
> that someone has taken the time to put this togther!

It isn't out there in the public yet, although I'd be willing to
put it somewhere accessible to the general TT-using world if
there's interest.  It's pretty spare right now, though.

> However, I'm unclear what the difference is between
> "/web/templates" and "/web/htdocs". I also pass vars
> to my process and I'm not sure from your doc how to do
> this (though see my example later).

OK, here's an explanation.  Keep in mind that this is designed to
be run offline, not from the web server.

 .  The COMPILE_DIR is where the compiled Template::Document objects
    will be put.

 .  Setting OUTPUT to /dev/null (only at pre-compilation time!) means
    that the output from this batch process will be discarded.
    OUTPUT need to be set to $r or *STDOUT or just removed for when
    the templates are called from within mod_perl.

 .  INCLUDE_DIR is a typo; it should be INCLUDE_PATH.
    INCLUDE_PATH is where TT will look for include files.  This is
    there so that the files that are found match what the web
    sever will find.  In your setup described below, this would be
    set to "$websrc:$websrc/lib".

 .  /web/htdocs is the DocumentRoot; this is where the mod_perl
    handler would be getting templates from.  The process sub
    BTW, should probably be doing something like:


    sub process {
        if (-e $_) {
            $t->process($_, { }) or warn $t->error;
        }
    }

> I've tried changing like this:
> 
> my $template = Template->new({
>         ABSOLUTE      => 1,
>         RELATIVE      => 1,
>         INCLUDE_PATH => "$websrc:$websrc/lib",
>         COMPILE_DIR => "/var/ttcache",
>         OUTPUT      => "/dev/null",
> 
>     });

If this is your mod_perl handler, take out the OUTPUT directive
there; that's only for when you are pre-compiling the templates.

The use of File::Find is only for precompiling that templates!
You shouldn't (can't) put that in or near a mod_perl handler; the
entirety of the Template stuff you'll need is:

my $template = Template->new({
        ABSOLUTE      => 1,
        RELATIVE      => 1,
        INCLUDE_PATH => "$websrc:$websrc/lib",
        COMPILE_DIR => "/var/ttcache",
    });

> I get no template output with OUTPUT => "/dev/null"
> (though I can get the handler to print output). 

Yup.

> It looks like in both cases /var/ttcache isn't
> building out sub directories
> (/var/ttcache/usr/local/upuzzles/*), but instead is
> putting all templates and lib items under the top
> level directory of /var/ttcache

That's weird, although I seem to remember someone saying
something about that on the list...  I wish I could remember
more, though.  What version of TT are you using?

> Are INCLUDE_DIR and INCLUDE_PATH the same?

Nope; that should be INCLUDE_PATH (error on my part).  Sorry
about that...

> Sorry for all these questions, but this has been a
> major issue with my TT launch...and the PHBs may want
> to return to ColdFusion if I don't get this figured
> out soon.

If you are really stuck you can email me off list, and I might be
able to help.

(darren)

-- 
If I worked as much as others I would do as little as they.


Reply via email to