Sergey Martynoff wrote:
> By the way, it will (possibly) be a good idea to have the ability
> to create system-wide autoloading plugin.
Interesting idea. One of the nice features of Catalyst, Maypole, etc.,
is the autoloading of controller and view modules - just drop the module
in the right directory and leave it to do the rest. I'll think on that
some more...
> I understand that I can preload module whed
> creating Template object - but I am working with dozens of
> independent scripts, which are using TT, and it is not always
> possible to modify them.
I typically do one of two things. I either have a PRE_PROCESS config
file in which I load all the plugins, etc., for the project. Or I create
a custom template module and customise the new() method. Or both.
package abw::Template::WithBellsOn;
use base 'Template';
sub new {
my $class = shift;
$class->SUPER::new({
VARIABLES => { ... },
INCLUDE_PATH => '/home/abw/templates',
PRE_PROCESS => 'site/config',
# ...etc...
});
}
If you're using ttree the --template_module=abw::Template::WithBellsOn
option invokes the custom template object. If you're doing something from
Perl, then simply create and use an abw::Template::WithBellsOn object
instead of a regular Template one.
For TT3 I'm thinking of adding a USE_PLUGINS option which would pre-USE
the specified plugins.
But of course, none of these help if you're in the situation where you
can't easily change the configuration of existing scripts. So I'm thinking
it would also be good to be able to specify TT options using one or more
environment variables, e.g. TEMPLATE_MODULE and/or TEMPLATE_CONFIG.
Cheers
A
_______________________________________________
templates mailing list
[email protected]
http://lists.template-toolkit.org/mailman/listinfo/templates