[%# # IMPORTANT NOTE # This documentation is generated automatically from source # templates. Any changes you make here may be lost. # # The 'docsrc' documentation source bundle is available for download # from http://www.template-toolkit.org/docs.html and contains all # the source templates, XML files, scripts, etc., from which the # documentation for the Template Toolkit is built. -%] [% META book = 'Modules' page = 'Plugins' %] [% WRAPPER toc; INCLUDE tocitem title='SYNOPSIS'; INCLUDE tocitem title='DESCRIPTION'; INCLUDE tocitem title='METHODS' subs=['new(\%params) ', 'fetch($name, @args)']; INCLUDE tocitem title='CONFIGURATION OPTIONS'; INCLUDE tocitem title='TEMPLATE TOOLKIT PLUGINS'; INCLUDE tocitem title='BUGS / ISSUES'; INCLUDE tocitem title='AUTHOR'; INCLUDE tocitem title='VERSION'; INCLUDE tocitem title='COPYRIGHT'; INCLUDE tocitem title='SEE ALSO'; END %] [% WRAPPER section title='SYNOPSIS' -%]
    use Template::Plugins;
    $plugin_provider = Template::Plugins->new(\%options);
    ($plugin, $error) = $plugin_provider->fetch($name, @args);
[%- END %] [% WRAPPER section title='DESCRIPTION' -%]

The Template::Plugins module defines a provider class which can be used to load and instantiate Template Toolkit plugin modules.

[%- END %] [% WRAPPER section title='METHODS' -%][% WRAPPER subsection title = 'new(\%params) ' -%]

Constructor method which instantiates and returns a reference to a Template::Plugins object. A reference to a hash array of configuration items may be passed as a parameter. These are described below.

Note that the Template.pm front-end module creates a Template::Plugins provider, passing all configuration items. Thus, the examples shown below in the form:

    $plugprov = Template::Plugins->new({
	PLUGIN_BASE => 'MyTemplate::Plugin',
        LOAD_PERL   => 1,
	...
    });

can also be used via the Template module as:

    $ttengine = Template->new({
	PLUGIN_BASE => 'MyTemplate::Plugin',
        LOAD_PERL   => 1,
	...
    });

as well as the more explicit form of:

    $plugprov = Template::Plugins->new({
	PLUGIN_BASE => 'MyTemplate::Plugin',
        LOAD_PERL   => 1,
	...
    });
    $ttengine = Template->new({
	LOAD_PLUGINS => [ $plugprov ],
    });
[%- END %] [% WRAPPER subsection title = 'fetch($name, @args)' -%]

Called to request that a plugin of a given name be provided. The relevant module is first loaded (if necessary) and the load() class method called to return the factory class name (usually the same package name) or a factory object (a prototype). The new() method is then called as a class or object method against the factory, passing all remaining parameters.

Returns a reference to a new plugin object or ($error, STATUS_ERROR) on error. May also return (undef, STATUS_DECLINED) to decline to serve the request. If TOLERANT is set then all errors will be returned as declines.

[%- END %] [%- END %] [% WRAPPER section title='CONFIGURATION OPTIONS' -%]

The following list details the configuration options that can be provided to the Template::Plugins new() constructor.

[%- END %] [% WRAPPER section title='TEMPLATE TOOLKIT PLUGINS' -%]

The following plugin modules are distributed with the Template Toolkit. Some of the plugins interface to external modules (detailed below) which should be downloaded from any CPAN site and installed before using the plugin.

[%- END %] [% WRAPPER section title='BUGS / ISSUES' -%] [%- END %] [% WRAPPER section title='AUTHOR' -%]

Andy Wardley <abw@kfs.org>

[% ttlink('http://www.andywardley.com/', 'http://www.andywardley.com/') -%]

[%- END %] [% WRAPPER section title='VERSION' -%]

Template Toolkit version 2.01, released on 30th March 2001.

[%- END %] [% WRAPPER section title='COPYRIGHT' -%]
  Copyright (C) 1996-2001 Andy Wardley.  All Rights Reserved.
  Copyright (C) 1998-2001 Canon Research Centre Europe Ltd.

This module is free software; you can redistribute it and/or modify it under the same terms as Perl itself.

[%- END %] [% WRAPPER section title='SEE ALSO' -%]

[% ttlink('Template', 'Template') -%], [% ttlink('Template::Plugin', 'Template::Plugin') -%], [% ttlink('Template::Context', 'Template::Context') -%]

[%- END %]