On Tue, Jul 1, 2008 at 12:27 PM, Blue Eyed Devil
<[EMAIL PROTECTED]> wrote:
>
>  The problem however is when you don't know what tag will be in the document

My guess is that you don't want to provide all possible combinations
of data to the template in case the template doesn't actually use the
data (ie you are wasting resources fetching and build all the
information even though the template doesn't use the majority of it).

What if you flipped things around and just passed a single object to
the template, and then let that object do the work that needs to be
done only when it is requested by the template.  Similar to what Josh
suggested, but with an object instead of a hash of values:

my $c = My::Template:Manager->new();

$template->process($template, { c => $c }, ...);

Then just use something like [% c.DATE %], which would then call the
perl method $c->DATE.  So you create a DATE subroutine in
My::Template:Manager that does exactly what you want it to do and this
method is called only when it is used in the template.

This is similar to what Catalyst and CGI::Application do to allow you
to call back into the framework from within the template.

Cheers,

Cees

_______________________________________________
templates mailing list
[email protected]
http://mail.template-toolkit.org/mailman/listinfo/templates

Reply via email to