Perl 一种动态更改Template::Toolkit中包含路径的方法
如果我有一个预加载的Template::Toolkit对象,例如在mod_perl环境中,有没有任何方法可以在不重新创建对象的情况下更改INCLUDE_PATH数组?我使用Template::Provider来实现此目的Perl 一种动态更改Template::Toolkit中包含路径的方法,perl,templates,fastcgi,mod-perl,Perl,Templates,Fastcgi,Mod Perl,如果我有一个预加载的Template::Toolkit对象,例如在mod_perl环境中,有没有任何方法可以在不重新创建对象的情况下更改INCLUDE_PATH数组?我使用Template::Provider来实现此目的 my $template_config = { INCLUDE_PATH => "/path/to/templates", ENCODING => 'utf8', }; # Create template_provider ma
my $template_config = {
INCLUDE_PATH => "/path/to/templates",
ENCODING => 'utf8',
};
# Create template_provider manually so that we can manipulate template path
# later.
my $template_provider = Template::Provider->new($template_config);
my $tt = Template->new({
LOAD_TEMPLATES => [$template_provider ],
PRE_CHOMP => 2,
POST_CHOMP => 3,
TRIM => 1,
ENCODING => 'utf8',
}) || die $Template::ERROR;
# somewhere else later
$template_provider->include_path([
"$dir/templates/$language",
"$dir/templates"]);