dss <[EMAIL PROTECTED]> said something to this effect on 08/20/2001:
> I'm fairly new to TT, and I am fortunate enough to be
> given the task to rid ourselves of coldfusion and
> replace it with TT (TT being my choice).

Good choice.

> I have several "tags" in a template that each query
> the  database, often the same table. Which is the
> better way to approach getting my data? 
> 
> 1) Using several "INCLUDE" directives in my template,
> each which query the database 
> 
> or
> 
> 2) Query the database in my handler, making the data
> available to all my INCLUDE directives.
> 
> It seems wasteful to query the same table in several
> INCLUDE directives when I could have just query that
> table once.

My advice would be to write some plugins that do the work, and
call the plugins from your templates.  For expensive calculations
(like database queries), have the plugins either be Singletons or
implement their own caches (I like Perrin Harkin's
Template::Plugin::Cache module that was posted a few weeks ago
see <URL:http://www.template-toolkit.org/pipermail/templates/2001-August/001320.html>),
although I don't know if this had made it to CPAN yet.

(darren)

-- 
You can never entirely stop being what you once were. That's why it's
important to be the right person today, and not put it off till tomorrow.
    -- Larry Wall


Reply via email to