Andy Wardley wrote:
Stas Bekman wrote:

Please notice that I'm after in-memory caching, since again, I don't want users to do any special setups,


Hi Stas,

I'm not sure I follow how you're planning to define the templates in the Perl module, but as long as the templates have names, they will be cached as compiled in memory.

So you could define all the templates using the BLOCK option, for example:

   my $tt = Template->new({
       BLOCKS => {
         header => '...',
         footer => '...',
         ...etc...
       }
   });

As long as the $tt object is persistant (i.e. a package var) then the compiled templates will remain cached in memory.

Does that help?

Thanks Andy. Could the caching docs section be ammended to say that? (all named blocks are cached).


At the moment they don't have names. I just call:

$tt->process($self->get_template_foo(), $self->get_data_foo())
     or warn $tt->error();
$tt->process$self->(get_template_bar(), $self->get_data_bar())
     or warn $tt->error();

The idea was to make Apache::VMonitor self-contained and all its methods and templates subclassable, so one needs to override a get_template_foo and/or get_data_bar method if they wish to change the template and/or and or the way the data is fed to it.

I suppose I could rewrite it so that it starts with:

   $tt ||= Template->new({
       BLOCKS => {
         foo => $self->get_template_foo(),
         bar => $self->get_template_bar(),
         ...etc...
       }
   });

which will work just fine if templates won't need to be changed between requests.

Thanks!

__________________________________________________________________
Stas Bekman            JAm_pH ------> Just Another mod_perl Hacker
http://stason.org/     mod_perl Guide ---> http://perl.apache.org
mailto:[EMAIL PROTECTED] http://use.perl.org http://apacheweek.com
http://modperlbook.org http://apache.org   http://ticketmaster.com


_______________________________________________ templates mailing list [EMAIL PROTECTED] http://lists.template-toolkit.org/mailman/listinfo/templates

Reply via email to