Nik Clayton wrote:
> The only thing I'm not happy with is the duplication between
> %filter_in and @plugins. Is there any mechanism I can use that, given
> a plugin name (or a plugin object) that can tell me the name of the
> filter method in that plugin, without needing to maintain a separate
> mapping?
You could implement a method in the plugin objects that returns the filter
name.
Then you could do something like this:
foreach my $name (@plugins) {
my $plugin = $context->plugin($name) || next;
my $filter = $context->filter($plugin->filter_name()) || next;
$text = &$filter($text);
}
Alternately, you could have the plugin return a filter object rather
than installing it in the context filters. This is what
Template::Plugin::Filter does.
Then you could do something like this:
foreach my $name (@plugins) {
my $plugin = $context->plugin($name) || next;
$text = $plugin->filter($text);
}
Although that's straying a little from the original purpose of using
filters.
HTH
A
_______________________________________________
templates mailing list
[email protected]
http://lists.template-toolkit.org/mailman/listinfo/templates