# perldoc > Template::Plugins

---
type: CommandReference
command: Template::Plugins
mode: perldoc
section: 3
source: perldoc
---

## Quick Reference

- `Template::Plugins->new(\%options)` — instantiate a plugin provider
- `$provider->fetch($name, @args)` — load and instantiate a plugin
- `PLUGINS => { name => 'Module::Name' }` — map plugin names to modules
- `PLUGIN_BASE => 'MyOrg::Template::Plugin'` — default prefix for plugin module resolution
- `LOAD_PERL => 1` — allow loading non-Template::Plugin modules
- `TOLERANT => 1` — ignore load errors, return STATUS_DECLINED
- `DEBUG => DEBUG_PLUGINS` — enable plugin debugging messages

## Name

Template::Plugins - Plugin provider module

## Synopsis

perl
use Template::Plugins;

$plugin_provider = Template::Plugins->new(\%options);

($plugin, $error) = $plugin_provider->fetch($name, @args);
## Options

- `PLUGINS => \%hash` — maps plugin names to Perl module names.  
  Example: `{ cgi => 'MyOrg::Template::Plugin::CGI' }`  
- `PLUGIN_BASE => $prefix | \@prefixes` — base namespace(s) to prepend when resolving plugin module names.  
  Example: `'MyOrg::Template::Plugin'` or `[ 'MyOrg::Template::Plugin', 'YourOrg::Template::Plugin' ]`  
- `LOAD_PERL => $bool` — if set, attempts to load any module (not just under `Template::Plugin` namespace) as a plugin. Note: such modules do not receive a `Template::Context` reference as the first argument to `new()`.  
- `TOLERANT => $bool` — if set, all plugin-load errors are converted to `STATUS_DECLINED` instead of raising an error.  
- `DEBUG => $flag` — enable debugging; set to include `DEBUG_PLUGINS` from `Template::Constants`.  

## Examples

**Using PLUGINS to map plugin names:**

perl
my $plugins = Template::Plugins->new({
    PLUGINS => {
        cgi => 'MyOrg::Template::Plugin::CGI',
        foo => 'MyOrg::Template::Plugin::Foo',
        bar => 'MyOrg::Template::Plugin::Bar',
    },
});
**Using PLUGIN_BASE with a single value:**

perl
my $plugins = Template::Plugins->new({
    PLUGIN_BASE => 'MyOrg::Template::Plugin',
});
**Using PLUGIN_BASE with multiple values:**

perl
my $plugins = Template::Plugins->new({
    PLUGIN_BASE => [ 'MyOrg::Template::Plugin', 'YourOrg::Template::Plugin' ],
});
**Using LOAD_PERL to load a regular Perl module as a plugin:**

perl
my $template = Template->new({
    LOAD_PERL => 1,
});
**Enabling plugin debugging:**

perl
use Template::Constants qw( :debug );
my $template = Template->new({
    DEBUG => DEBUG_FILTERS | DEBUG_PLUGINS,
});
**Passing the plugin provider explicitly to Template:**

perl
my $plugprov = Template::Plugins->new({ ... });
my $ttengine = Template->new({
    LOAD_PLUGINS => [ $plugprov ],
});
## See Also

- [Template::Manual::Plugins](https://www.chedong.com/phpMan.php/perldoc/Template%3A%3AManual%3A%3APlugins/markdown) - list of all plugin modules
- [Template::Plugin](https://www.chedong.com/phpMan.php/perldoc/Template%3A%3APlugin/markdown) - base class for plugins
- [Template::Context](https://www.chedong.com/phpMan.php/perldoc/Template%3A%3AContext/markdown) - context object passed to plugin constructors
- Template - the main template processing engine