本文介绍了一种在FLY上更改Template :: Toolkit中的INCLUDE_PATH的方法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如果我有一个预加载的Template :: Toolkit对象,例如在mod_perl环境中,有什么方法可以更改INCLUDE_PATH数组而无需重新创建该对象?
If I have a preloaded Template::Toolkit object, in mod_perl enviroment for example, is there any way to change INCLUDE_PATH array without recreating the object?
推荐答案
我为此使用了Template :: Provider
I use the Template::Provider for this
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"]);
这篇关于一种在FLY上更改Template :: Toolkit中的INCLUDE_PATH的方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!