Template::Constants(3pm) User Contributed Perl Documentation Template::Constants(3pm)NAME
Template::Constants - Defines constants for the Template Toolkit
SYNOPSIS
use Template::Constants qw( :status :error :all );
DESCRIPTION
The "Template::Constants" modules defines, and optionally exports into the caller's namespace, a number of constants used by the Template
package.
Constants may be used by specifying the "Template::Constants" package explicitly:
use Template::Constants;
print Template::Constants::STATUS_DECLINED;
Constants may be imported into the caller's namespace by naming them as options to the "use Template::Constants" statement:
use Template::Constants qw( STATUS_DECLINED );
print STATUS_DECLINED;
Alternatively, one of the following tagset identifiers may be specified to import sets of constants: '":status"', '":error"', '":all"'.
use Template::Constants qw( :status );
print STATUS_DECLINED;
Consult the documentation for the "Exporter" module for more information on exporting variables.
EXPORTABLE TAG SETS
The following tag sets and associated constants are defined:
:status
STATUS_OK # no problem, continue
STATUS_RETURN # ended current block then continue (ok)
STATUS_STOP # controlled stop (ok)
STATUS_DONE # iterator is all done (ok)
STATUS_DECLINED # provider declined to service request (ok)
STATUS_ERROR # general error condition (not ok)
:error
ERROR_RETURN # return a status code (e.g. 'stop')
ERROR_FILE # file error: I/O, parse, recursion
ERROR_UNDEF # undefined variable value used
ERROR_PERL # error in [% PERL %] block
ERROR_FILTER # filter error
ERROR_PLUGIN # plugin error
:chomp # for PRE_CHOMP and POST_CHOMP
CHOMP_NONE # do not remove whitespace
CHOMP_ONE # remove whitespace to newline
CHOMP_ALL # old name for CHOMP_ONE (deprecated)
CHOMP_COLLAPSE # collapse whitespace to a single space
CHOMP_GREEDY # remove all whitespace including newlines
:debug
DEBUG_OFF # do nothing
DEBUG_ON # basic debugging flag
DEBUG_UNDEF # throw undef on undefined variables
DEBUG_VARS # general variable debugging
DEBUG_DIRS # directive debugging
DEBUG_STASH # general stash debugging
DEBUG_CONTEXT # context debugging
DEBUG_PARSER # parser debugging
DEBUG_PROVIDER # provider debugging
DEBUG_PLUGINS # plugins debugging
DEBUG_FILTERS # filters debugging
DEBUG_SERVICE # context debugging
DEBUG_ALL # everything
DEBUG_CALLER # add caller file/line info
DEBUG_FLAGS # bitmap used internally
:all
All the above constants.
AUTHOR
Andy Wardley <abw@wardley.org> <http://wardley.org/>
COPYRIGHT
Copyright (C) 1996-2007 Andy Wardley. All Rights Reserved.
This module is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
SEE ALSO
Template, "Exporter"
perl v5.14.2 2011-12-20 Template::Constants(3pm)
Check Out this Related Man Page
Template::Plugins(3) User Contributed Perl Documentation Template::Plugins(3)NAME
Template::Plugins - Plugin provider module
SYNOPSIS
use Template::Plugins;
$plugin_provider = Template::Plugins->new(\%options);
($plugin, $error) = $plugin_provider->fetch($name, @args);
DESCRIPTION
The "Template::Plugins" module defines a provider class which can be used to load and instantiate Template Toolkit plugin modules.
METHODS
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 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 ],
});
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.
CONFIGURATION OPTIONS
The following list summarises the configuration options that can be provided to the "Template::Plugins" new() constructor. Please consult
Template::Manual::Config for further details and examples of each configuration option in use.
PLUGINS
The PLUGINS option can be used to provide a reference to a hash array that maps plugin names to Perl module names.
my $plugins = Template::Plugins->new({
PLUGINS => {
cgi => 'MyOrg::Template::Plugin::CGI',
foo => 'MyOrg::Template::Plugin::Foo',
bar => 'MyOrg::Template::Plugin::Bar',
},
});
PLUGIN_BASE
If a plugin is not defined in the PLUGINS hash then the PLUGIN_BASE is used to attempt to construct a correct Perl module name which can be
successfully loaded.
# single value PLUGIN_BASE
my $plugins = Template::Plugins->new({
PLUGIN_BASE => 'MyOrg::Template::Plugin',
});
# multiple value PLUGIN_BASE
my $plugins = Template::Plugins->new({
PLUGIN_BASE => [ 'MyOrg::Template::Plugin',
'YourOrg::Template::Plugin' ],
});
LOAD_PERL
The LOAD_PERL option can be set to allow you to load regular Perl modules (i.e. those that don't reside in the "Template::Plugin" or
another user-defined namespace) as plugins.
If a plugin cannot be loaded using the PLUGINS or PLUGIN_BASE approaches then, if the LOAD_PERL is set, the provider will make a final
attempt to load the module without prepending any prefix to the module path.
Unlike regular plugins, modules loaded using LOAD_PERL do not receive a Template::Context reference as the first argument to the "new()"
constructor method.
TOLERANT
The TOLERANT flag can be set to indicate that the "Template::Plugins" module should ignore any errors encountered while loading a plugin
and instead return "STATUS_DECLINED".
DEBUG
The DEBUG option can be used to enable debugging messages for the "Template::Plugins" module by setting it to include the "DEBUG_PLUGINS"
value.
use Template::Constants qw( :debug );
my $template = Template->new({
DEBUG => DEBUG_FILTERS | DEBUG_PLUGINS,
});
TEMPLATE TOOLKIT PLUGINS
Please see Template::Manual::Plugins For a complete list of all the plugin modules distributed with the Template Toolkit.
AUTHOR
Andy Wardley <abw@wardley.org> <http://wardley.org/>
COPYRIGHT
Copyright (C) 1996-2007 Andy Wardley. All Rights Reserved.
This module is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
SEE ALSO
Template::Manual::Plugins, Template::Plugin, Template::Context, Template.
perl v5.12.1 2008-12-09 Template::Plugins(3)