Perrin Harkins wrote:
> Caching the object is very important. It makes a big difference in
> performance. Please change that.
>
> (Hmm... maybe CPAN needs some kind of Template::Toolkit::Singleton
> module to make this more obvious to people.)
For TT3 I'm thinking that the Template module should allow its methods
to be called as class methods.
use Template;
Template->process(...);
When called in this way, the process() and other related methods would
create and operate on a singleton object. It might be the case that you
have to set an extra configuration option like 'singleton' or 'reusable'
to invoke this behaviour (otherwise it creates a new object per invocation),
or it might be the default - I haven't decided yet. But either way it should
be easy to enable/disable.
Configuration options for the singleton could be defined as 'use' options,
e.g.
use Template templates_path => '/home/abw/templates'
interpolate => 1;
Or by calling a config() method:
use Template;
Template->config( templates_path => '/home/abw/templates',
interpolate => 1 );
Template->process(...);
Or by creating your own subclass and defining a hash array of options as
the $CONFIG package variable:
package abw::Template;
use base 'Template';
our $CONFIG = {
templates_path => '/home/abw/templates',
interpolate => 1,
};
package main;
abw::Template->process(...);
Note that templates_path is the new TT3 name for INCLUDE_PATH and other
options like INTERPOLATE are now lower case by default. However, the
Template::TT2 module will provide a backwards compatibility interface
for those who want to use the old skool options.
# either
use Template::TT2 INCLUDE_PATH => '/home/abw/templates';
# or
use Template::TT2;
Template::TT2->config( INCLUDE_PATH => ... );
# and so on...
Comments welcome.
A
_______________________________________________
templates mailing list
[email protected]
http://lists.template-toolkit.org/mailman/listinfo/templates