Linux and UNIX Man Pages

Linux & Unix Commands - Search Man Pages

template::exception(3) [centos man page]

Template::Exception(3)					User Contributed Perl Documentation				    Template::Exception(3)

NAME
Template::Exception - Exception handling class module SYNOPSIS
use Template::Exception; my $exception = Template::Exception->new($type, $info); $type = $exception->type; $info = $exception->info; ($type, $info) = $exception->type_info; print $exception->as_string(); $handler = $exception->select_handler(@candidates); DESCRIPTION
The "Template::Exception" module defines an object class for representing exceptions within the template processing life cycle. Exceptions can be raised by modules within the Template Toolkit, or can be generated and returned by user code bound to template variables. Exceptions can be raised in a template using the "THROW" directive, [% THROW user.login 'no user id: please login' %] or by calling the throw() method on the current Template::Context object, $context->throw('user.passwd', 'Incorrect Password'); $context->throw('Incorrect Password'); # type 'undef' or from Perl code by calling "die()" with a "Template::Exception" object, die (Template::Exception->new('user.denied', 'Invalid User ID')); or by simply calling "die()" with an error string. This is automagically caught and converted to an exception of '"undef"' type (that's the literal string '"undef"' rather than Perl's undefined value) which can then be handled in the usual way. die "I'm sorry Dave, I can't do that"; Each exception is defined by its type and a information component (e.g. error message). The type can be any identifying string and may contain dotted components (e.g. '"foo"', '"foo.bar"', '"foo.bar.baz"'). Exception types are considered to be hierarchical such that '"foo.bar"' would be a specific type of the more general '"foo"' type. METHODS
type() Returns the exception type. info() Returns the exception information. 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, Template::Context perl v5.16.3 2011-12-20 Template::Exception(3)

Check Out this Related Man Page

Template::Filters(3)					User Contributed Perl Documentation				      Template::Filters(3)

NAME
Template::Filters - Post-processing filters for template blocks SYNOPSIS
use Template::Filters; $filters = Template::Filters->new(\%config); ($filter, $error) = $filters->fetch($name, @args, $context); if ($filter) { print &$filter("some text"); } else { print "Could not fetch $name filter: $error "; } DESCRIPTION
The "Template::Filters" module implements a provider for creating subroutines that implement the standard filters. Additional custom filters may be provided via the FILTERS configuration option. METHODS
new(\%params) Constructor method which instantiates and returns a reference to a "Template::Filters" object. A reference to a hash array of configuration items may be passed as a parameter. These are described below. my $filters = Template::Filters->new({ FILTERS => { ... }, }); my $template = Template->new({ LOAD_FILTERS => [ $filters ], }); A default "Template::Filters" module is created by the Template module if the LOAD_FILTERS option isn't specified. All configuration parameters are forwarded to the constructor. $template = Template->new({ FILTERS => { ... }, }); fetch($name, @args, $context) Called to request that a filter of a given name be provided. The name of the filter should be specified as the first parameter. This should be one of the standard filters or one specified in the FILTERS configuration hash. The second argument should be a reference to an array containing configuration parameters for the filter. This may be specified as 0, or undef where no parameters are provided. The third argument should be a reference to the current Template::Context object. The method returns a reference to a filter sub-routine on success. It may also return "(undef, STATUS_DECLINE)" to decline the request, to allow delegation onto other filter providers in the LOAD_FILTERS chain of responsibility. On error, "($error, STATUS_ERROR)" is returned where $error is an error message or Template::Exception object indicating the error that occurred. When the "TOLERANT" option is set, errors are automatically downgraded to a "STATUS_DECLINE" response. use_html_entities() This class method can be called to configure the "html_entity" filter to use the HTML::Entities module. An error will be raised if it is not installed on your system. use Template::Filters; Template::Filters->use_html_entities(); use_apache_util() This class method can be called to configure the "html_entity" filter to use the Apache::Util module. An error will be raised if it is not installed on your system. use Template::Filters; Template::Filters->use_apache_util(); CONFIGURATION OPTIONS
The following list summarises the configuration options that can be provided to the "Template::Filters" new() constructor. Please see Template::Manual::Config for further information about each option. FILTERS The FILTERS option can be used to specify custom filters which can then be used with the FILTER directive like any other. These are added to the standard filters which are available by default. $filters = Template::Filters->new({ FILTERS => { 'sfilt1' => &static_filter, 'dfilt1' => [ &dyanamic_filter_factory, 1 ], }, }); TOLERANT The TOLERANT flag can be set to indicate that the "Template::Filters" module should ignore any errors and instead return "STATUS_DECLINED". DEBUG The DEBUG option can be used to enable debugging messages for the Template::Filters module by setting it to include the "DEBUG_FILTERS" value. use Template::Constants qw( :debug ); my $template = Template->new({ DEBUG => DEBUG_FILTERS | DEBUG_PLUGINS, }); STANDARD FILTERS
Please see Template::Manual::Filters for a list of the filters provided with the Template Toolkit, complete with examples of use. 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::Filters, Template, Template::Context perl v5.12.1 2009-07-04 Template::Filters(3)
Man Page