On Mon, 26 Jan 2004, Franco Bagnoli wrote:
> I would like to define a plugin and a filter at the same time, say
>
> [% USE format=MyFormat(options) %]
>
> [% format("text") %]
>
> or
>
> [% FILTER format %]
>
> text
>
> [% END %]
>
> Is it possible? (there is no Filter dir in which to put filters, and I do
> not want to alter Filter.pm)
To create a filter in a plugin, just call the define_filter()
method on the $context (which you get as the second argument to
load() ).
Info on writing a plugin:
http://template-toolkit.org/docs/aqua/Modules/Template/Plugin.html
Some good examples for using define_filter() (under the FILTERS
section):
http://template-toolkit.org/docs/aqua/Manual/Config.html#Plugins_and_Filters
Also, there's a section in the fabulous new Badger Book (Perl
Template Toolkit from O'Reilly and Associates) which answers this
question directly. See "Defining Filters from Within a Plugin" on
page 317.
> Another "small" question: Am I obliged to put plugins in just one place or
> there is some configuration option for fetching plugins in alternate
> places?
See the PLUGIN_BASE configuration option here:
http://template-toolkit.org/docs/aqua/Manual/Config.html#Plugins_and_Filters
I think it, along with any 'use lib ...' lines you need to expand
@INC's vista, will suit your needs nicely.
Take care,
Dave
/L\_/E\_/A\_/R\_/N\_/T\_/E\_/A\_/C\_/H\_/L\_/E\_/A\_/R\_/N\
Dave Cash Power to the People!
Frolicking in Fields of Garlic Right On-Line!
[EMAIL PROTECTED] Dig it all.
_______________________________________________
templates mailing list
[EMAIL PROTECTED]
http://lists.template-toolkit.org/mailman/listinfo/templates