| 1 | #============================================================= -*-Perl-*- | ||||||||||||||||||||||||||||
| 2 | # | ||||||||||||||||||||||||||||
| 3 | # Template::Service | ||||||||||||||||||||||||||||
| 4 | # | ||||||||||||||||||||||||||||
| 5 | # DESCRIPTION | ||||||||||||||||||||||||||||
| 6 | # Module implementing a template processing service which wraps a | ||||||||||||||||||||||||||||
| 7 | # template within PRE_PROCESS and POST_PROCESS templates and offers | ||||||||||||||||||||||||||||
| 8 | # ERROR recovery. | ||||||||||||||||||||||||||||
| 9 | # | ||||||||||||||||||||||||||||
| 10 | # AUTHOR | ||||||||||||||||||||||||||||
| 11 | # Andy Wardley <abw@wardley.org> | ||||||||||||||||||||||||||||
| 12 | # | ||||||||||||||||||||||||||||
| 13 | # COPYRIGHT | ||||||||||||||||||||||||||||
| 14 | # Copyright (C) 1996-2022 Andy Wardley. All Rights Reserved. | ||||||||||||||||||||||||||||
| 15 | # | ||||||||||||||||||||||||||||
| 16 | # This module is free software; you can redistribute it and/or | ||||||||||||||||||||||||||||
| 17 | # modify it under the same terms as Perl itself. | ||||||||||||||||||||||||||||
| 18 | # | ||||||||||||||||||||||||||||
| 19 | #============================================================================ | ||||||||||||||||||||||||||||
| 20 | |||||||||||||||||||||||||||||
| 21 | package Template::Service; | ||||||||||||||||||||||||||||
| 22 | |||||||||||||||||||||||||||||
| 23 | 116 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 24 | 116 | ▶ | use warnings; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 25 | 116 | ▶ | use base 'Template::Base'; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 26 | 116 | ▶ | use Template::Config; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 27 | 116 | ▶ | use Template::Exception; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 28 | 116 | ▶ | use Template::Constants; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 29 | 116 | ▶ | use Scalar::Util 'blessed'; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 30 | |||||||||||||||||||||||||||||
| 31 | 116 | ▶ | use constant EXCEPTION => 'Template::Exception'; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 32 | |||||||||||||||||||||||||||||
| 33 | 116 | our $VERSION = '3.106'; | |||||||||||||||||||||||||||
| 34 | 116 | ▶ | our $DEBUG = 0 unless defined $DEBUG; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 35 | 116 | our $ERROR = ''; | |||||||||||||||||||||||||||
| 36 | |||||||||||||||||||||||||||||
| 37 | |||||||||||||||||||||||||||||
| 38 | #======================================================================== | ||||||||||||||||||||||||||||
| 39 | # ----- PUBLIC METHODS ----- | ||||||||||||||||||||||||||||
| 40 | #======================================================================== | ||||||||||||||||||||||||||||
| 41 | |||||||||||||||||||||||||||||
| 42 | #------------------------------------------------------------------------ | ||||||||||||||||||||||||||||
| 43 | # process($template, \%params) | ||||||||||||||||||||||||||||
| 44 | # | ||||||||||||||||||||||||||||
| 45 | # Process a template within a service framework. A service may encompass | ||||||||||||||||||||||||||||
| 46 | # PRE_PROCESS and POST_PROCESS templates and an ERROR hash which names | ||||||||||||||||||||||||||||
| 47 | # templates to be substituted for the main template document in case of | ||||||||||||||||||||||||||||
| 48 | # error. Each service invocation begins by resetting the state of the | ||||||||||||||||||||||||||||
| 49 | # context object via a call to reset(). The AUTO_RESET option may be set | ||||||||||||||||||||||||||||
| 50 | # to 0 (default: 1) to bypass this step. | ||||||||||||||||||||||||||||
| 51 | #------------------------------------------------------------------------ | ||||||||||||||||||||||||||||
| 52 | |||||||||||||||||||||||||||||
| 53 | 1406 | ▶ | sub process { | ||||||||||||||||||||||||||
|
Subroutine
process: called CC=23 SCAR=31.9
Pod
documented
| |||||||||||||||||||||||||||||
| 54 | 1406 | my ($self, $template, $params) = @_; | |||||||||||||||||||||||||||
| 55 | 1406 | my $context = $self->{ CONTEXT }; | |||||||||||||||||||||||||||
| 56 | 1406 | my ($name, $output, $procout, $error); | |||||||||||||||||||||||||||
| 57 | 1406 | $output = ''; | |||||||||||||||||||||||||||
| 58 | |||||||||||||||||||||||||||||
| 59 | $self->debug( | ||||||||||||||||||||||||||||
| 60 | "process($template, ", | ||||||||||||||||||||||||||||
| 61 | defined $params ? $params : '<no params>', | ||||||||||||||||||||||||||||
| 62 | ')' | ||||||||||||||||||||||||||||
| 63 | 1406 | ▶ | ) if $self->{ DEBUG }; | ||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||
| 64 | |||||||||||||||||||||||||||||
| 65 | $context->reset() | ||||||||||||||||||||||||||||
| 66 | 1406 | ▶ | if $self->{ AUTO_RESET }; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 67 | |||||||||||||||||||||||||||||
| 68 | # pre-request compiled template from context so that we can alias it | ||||||||||||||||||||||||||||
| 69 | # in the stash for pre-processed templates to reference | ||||||||||||||||||||||||||||
| 70 | 1406 | eval { $template = $context->template($template) }; | |||||||||||||||||||||||||||
| 71 | 1406 | ▶ | return $self->error($@) | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 72 | if $@; | ||||||||||||||||||||||||||||
| 73 | |||||||||||||||||||||||||||||
| 74 | # localise the variable stash with any parameters passed | ||||||||||||||||||||||||||||
| 75 | # and set the 'template' variable | ||||||||||||||||||||||||||||
| 76 | 1403 | ▶ | $params ||= { }; | ||||||||||||||||||||||||||
|
Condition100%2/2
$params ||= {}
MC/DC100%1/1
$params ||= {}
$params
Truth table100%2/2
A
A= $params
| |||||||||||||||||||||||||||||
| 77 | # TODO: change this to C<||=> so we can use a template parameter | ||||||||||||||||||||||||||||
| 78 | 1403 | ▶ | $params->{ template } = $template | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 79 | unless ref $template eq 'CODE'; | ||||||||||||||||||||||||||||
| 80 | 1403 | $context->localise($params); | |||||||||||||||||||||||||||
| 81 | |||||||||||||||||||||||||||||
| 82 | SERVICE: { | ||||||||||||||||||||||||||||
| 83 | # PRE_PROCESS | ||||||||||||||||||||||||||||
| 84 | 1403 | eval { | |||||||||||||||||||||||||||
| 85 | 1403 | foreach $name (@{ $self->{ PRE_PROCESS } }) { | |||||||||||||||||||||||||||
| 86 | 30 | ▶ | $self->debug("PRE_PROCESS: $name") if $self->{ DEBUG }; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 87 | 30 | $output .= $context->process($name); | |||||||||||||||||||||||||||
| 88 | } | ||||||||||||||||||||||||||||
| 89 | }; | ||||||||||||||||||||||||||||
| 90 | 1403 | ▶ | last SERVICE if ($error = $@); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 91 | |||||||||||||||||||||||||||||
| 92 | # PROCESS | ||||||||||||||||||||||||||||
| 93 | 1403 | eval { | |||||||||||||||||||||||||||
| 94 | 1403 | ▶ | foreach $name (@{ $self->{ PROCESS } || [ $template ] }) { | ||||||||||||||||||||||||||
|
Condition100%2/2
$self->{'PROCESS'} || [$template]
MC/DC100%1/1
$self->{'PROCESS'} || [$template]
$self->{'PROCESS'}
Truth table100%2/2
A
A= $self->{'PROCESS'}
| |||||||||||||||||||||||||||||
| 95 | 1403 | ▶ | $self->debug("PROCESS: $name") if $self->{ DEBUG }; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 96 | 1403 | $procout .= $context->process($name); | |||||||||||||||||||||||||||
| 97 | } | ||||||||||||||||||||||||||||
| 98 | }; | ||||||||||||||||||||||||||||
| 99 | 1403 | ▶ | if ($error = $@) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 100 | last SERVICE | ||||||||||||||||||||||||||||
| 101 | 22 | ▶ | unless defined ($procout = $self->_recover(\$error)); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 102 | } | ||||||||||||||||||||||||||||
| 103 | |||||||||||||||||||||||||||||
| 104 | 1394 | ▶ | if (defined $procout) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 105 | # WRAPPER | ||||||||||||||||||||||||||||
| 106 | 1393 | eval { | |||||||||||||||||||||||||||
| 107 | 1393 | foreach $name (reverse @{ $self->{ WRAPPER } }) { | |||||||||||||||||||||||||||
| 108 | 3 | ▶ | $self->debug("WRAPPER: $name") if $self->{ DEBUG }; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 109 | 3 | $procout = $context->process($name, { content => $procout }); | |||||||||||||||||||||||||||
| 110 | } | ||||||||||||||||||||||||||||
| 111 | }; | ||||||||||||||||||||||||||||
| 112 | 1393 | ▶ | last SERVICE if ($error = $@); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 113 | 1393 | $output .= $procout; | |||||||||||||||||||||||||||
| 114 | } | ||||||||||||||||||||||||||||
| 115 | |||||||||||||||||||||||||||||
| 116 | # POST_PROCESS | ||||||||||||||||||||||||||||
| 117 | 1394 | eval { | |||||||||||||||||||||||||||
| 118 | 1394 | foreach $name (@{ $self->{ POST_PROCESS } }) { | |||||||||||||||||||||||||||
| 119 | 17 | ▶ | $self->debug("POST_PROCESS: $name") if $self->{ DEBUG }; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 120 | 17 | $output .= $context->process($name); | |||||||||||||||||||||||||||
| 121 | } | ||||||||||||||||||||||||||||
| 122 | }; | ||||||||||||||||||||||||||||
| 123 | 1394 | ▶ | last SERVICE if ($error = $@); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 124 | } | ||||||||||||||||||||||||||||
| 125 | |||||||||||||||||||||||||||||
| 126 | 1403 | $context->delocalise(); | |||||||||||||||||||||||||||
| 127 | 1403 | delete $params->{ template }; | |||||||||||||||||||||||||||
| 128 | |||||||||||||||||||||||||||||
| 129 | 1403 | ▶ | if ($error) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 130 | # $error = $error->as_string if ref $error; | ||||||||||||||||||||||||||||
| 131 | 9 | return $self->error($error); | |||||||||||||||||||||||||||
| 132 | } | ||||||||||||||||||||||||||||
| 133 | |||||||||||||||||||||||||||||
| 134 | 1394 | return $output; | |||||||||||||||||||||||||||
| 135 | } | ||||||||||||||||||||||||||||
| 136 | |||||||||||||||||||||||||||||
| 137 | |||||||||||||||||||||||||||||
| 138 | #------------------------------------------------------------------------ | ||||||||||||||||||||||||||||
| 139 | # context() | ||||||||||||||||||||||||||||
| 140 | # | ||||||||||||||||||||||||||||
| 141 | # Returns the internal CONTEXT reference. | ||||||||||||||||||||||||||||
| 142 | #------------------------------------------------------------------------ | ||||||||||||||||||||||||||||
| 143 | |||||||||||||||||||||||||||||
| 144 | 3 | ▶ | sub context { | ||||||||||||||||||||||||||
|
Subroutine
context: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 145 | 3 | return $_[0]->{ CONTEXT }; | |||||||||||||||||||||||||||
| 146 | } | ||||||||||||||||||||||||||||
| 147 | |||||||||||||||||||||||||||||
| 148 | |||||||||||||||||||||||||||||
| 149 | #======================================================================== | ||||||||||||||||||||||||||||
| 150 | # -- PRIVATE METHODS -- | ||||||||||||||||||||||||||||
| 151 | #======================================================================== | ||||||||||||||||||||||||||||
| 152 | |||||||||||||||||||||||||||||
| 153 | 253 | ▶ | sub _init { | ||||||||||||||||||||||||||
|
Subroutine
_init: called CC=12 SCAR=25.2
| |||||||||||||||||||||||||||||
| 154 | 253 | my ($self, $config) = @_; | |||||||||||||||||||||||||||
| 155 | 253 | my ($item, $data, $context, $block, $blocks); | |||||||||||||||||||||||||||
| 156 | 253 | ▶ | my $delim = $config->{ DELIMITER } // ':'; | ||||||||||||||||||||||||||
|
Condition50%1/2
$config->{"DELIMITER"} // ":"
MC/DC0%0/1
$config->{"DELIMITER"} // ":"
$config->{"DELIMITER"}
Truth table50%1/2
A
A= $config->{"DELIMITER"}
| |||||||||||||||||||||||||||||
| 157 | |||||||||||||||||||||||||||||
| 158 | # coerce PRE_PROCESS, PROCESS and POST_PROCESS to arrays if necessary, | ||||||||||||||||||||||||||||
| 159 | # by splitting on non-word characters | ||||||||||||||||||||||||||||
| 160 | 253 | foreach $item (qw( PRE_PROCESS PROCESS POST_PROCESS WRAPPER )) { | |||||||||||||||||||||||||||
| 161 | 1012 | $data = $config->{ $item }; | |||||||||||||||||||||||||||
| 162 | 1012 | ▶ | $self->{ $item } = [ ], next unless (defined $data); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 163 | 23 | ▶ | $data = [ split($delim, $data || '') ] | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%2/2
$data || ''
MC/DC100%1/1
$data || ''
$data
Truth table100%2/2
A
A= $data
| |||||||||||||||||||||||||||||
| 164 | unless ref $data eq 'ARRAY'; | ||||||||||||||||||||||||||||
| 165 | 23 | $self->{ $item } = $data; | |||||||||||||||||||||||||||
| 166 | } | ||||||||||||||||||||||||||||
| 167 | # unset PROCESS option unless explicitly specified in config | ||||||||||||||||||||||||||||
| 168 | $self->{ PROCESS } = undef | ||||||||||||||||||||||||||||
| 169 | 253 | ▶ | unless defined $config->{ PROCESS }; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 170 | |||||||||||||||||||||||||||||
| 171 | 253 | ▶ | $self->{ ERROR } = $config->{ ERROR } || $config->{ ERRORS }; | ||||||||||||||||||||||||||
|
Condition66%2/3
$config->{'ERROR'} || $config->{'ERRORS'}
MC/DC50%1/2
$config->{'ERROR'} || $config->{'ERRORS'}
$config->{'ERROR'}
$config->{'ERRORS'}
Truth table66%2/3
A || B
A= $config->{'ERROR'}B= $config->{'ERRORS'}
| |||||||||||||||||||||||||||||
| 172 | 253 | ▶ | $self->{ AUTO_RESET } = $config->{ AUTO_RESET } // 1; | ||||||||||||||||||||||||||
|
Condition100%2/2
$config->{"AUTO_RESET"} // 1
MC/DC100%1/1
$config->{"AUTO_RESET"} // 1
$config->{"AUTO_RESET"}
Truth table100%2/2
A
A= $config->{"AUTO_RESET"}
| |||||||||||||||||||||||||||||
| 173 | 253 | ▶ | $self->{ DEBUG } = ( $config->{ DEBUG } || 0 ) | ||||||||||||||||||||||||||
|
Condition100%2/2
$config->{'DEBUG'} || 0
MC/DC100%1/1
$config->{'DEBUG'} || 0
$config->{'DEBUG'}
Truth table100%2/2
A
A= $config->{'DEBUG'}
| |||||||||||||||||||||||||||||
| 174 | & Template::Constants::DEBUG_SERVICE; | ||||||||||||||||||||||||||||
| 175 | |||||||||||||||||||||||||||||
| 176 | $context = $self->{ CONTEXT } = $config->{ CONTEXT } | ||||||||||||||||||||||||||||
| 177 | 253 | ▶ | || Template::Config->context($config) | ||||||||||||||||||||||||||
|
Condition40%2/5
$config->{'CONTEXT'} || 'Template::Config'->context($config) || (return $self->error('Template::Config'->error))
$config->{"CONTEXT"} or "Template::Config"->context($config)
MC/DC0%0/2
$config->{'CONTEXT'} || 'Template::Config'->context($config) || (return $self->error('Template::Config'->error))
$config->{"CONTEXT"}
"Template::Config"->context($config)
Truth table33%1/3
A or B
A= $config->{"CONTEXT"}B= "Template::Config"->context($config)
| |||||||||||||||||||||||||||||
| 178 | || return $self->error(Template::Config->error); | ||||||||||||||||||||||||||||
| 179 | |||||||||||||||||||||||||||||
| 180 | 253 | return $self; | |||||||||||||||||||||||||||
| 181 | } | ||||||||||||||||||||||||||||
| 182 | |||||||||||||||||||||||||||||
| 183 | |||||||||||||||||||||||||||||
| 184 | #------------------------------------------------------------------------ | ||||||||||||||||||||||||||||
| 185 | # _recover(\$exception) | ||||||||||||||||||||||||||||
| 186 | # | ||||||||||||||||||||||||||||
| 187 | # Examines the internal ERROR hash array to find a handler suitable | ||||||||||||||||||||||||||||
| 188 | # for the exception object passed by reference. Selecting the handler | ||||||||||||||||||||||||||||
| 189 | # is done by delegation to the exception's select_handler() method, | ||||||||||||||||||||||||||||
| 190 | # passing the set of handler keys as arguments. A 'default' handler | ||||||||||||||||||||||||||||
| 191 | # may also be provided. The handler value represents the name of a | ||||||||||||||||||||||||||||
| 192 | # template which should be processed. | ||||||||||||||||||||||||||||
| 193 | #------------------------------------------------------------------------ | ||||||||||||||||||||||||||||
| 194 | |||||||||||||||||||||||||||||
| 195 | 22 | ▶ | sub _recover { | ||||||||||||||||||||||||||
|
Subroutine
_recover: called CC=13 SCAR=28.0
| |||||||||||||||||||||||||||||
| 196 | 22 | my ($self, $error) = @_; | |||||||||||||||||||||||||||
| 197 | 22 | my $context = $self->{ CONTEXT }; | |||||||||||||||||||||||||||
| 198 | 22 | my ($hkey, $handler, $output); | |||||||||||||||||||||||||||
| 199 | |||||||||||||||||||||||||||||
| 200 | # there shouldn't ever be a non-exception object received at this | ||||||||||||||||||||||||||||
| 201 | # point... unless a module like CGI::Carp messes around with the | ||||||||||||||||||||||||||||
| 202 | # DIE handler. | ||||||||||||||||||||||||||||
| 203 | return undef | ||||||||||||||||||||||||||||
| 204 | 22 | ▶ | unless blessed($$error) && $$error->isa(EXCEPTION); | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
builtin::blessed($$error) and $$error->isa("Template::Exception")
MC/DC0%0/2
builtin::blessed($$error) and $$error->isa("Template::Exception")
builtin::blessed($$error)
$$error->isa("Template::Exception")
Truth table33%1/3
A and B
A= builtin::blessed($$error)B= $$error->isa("Template::Exception")
| |||||||||||||||||||||||||||||
| 205 | |||||||||||||||||||||||||||||
| 206 | # a 'stop' exception is thrown by [% STOP %] - we return the output | ||||||||||||||||||||||||||||
| 207 | # buffer stored in the exception object | ||||||||||||||||||||||||||||
| 208 | 22 | ▶ | return $$error->text() | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 209 | if $$error->type() eq 'stop'; | ||||||||||||||||||||||||||||
| 210 | |||||||||||||||||||||||||||||
| 211 | my $handlers = $self->{ ERROR } | ||||||||||||||||||||||||||||
| 212 | 13 | ▶ | || return undef; ## RETURN | ||||||||||||||||||||||||||
|
Condition100%2/2
$self->{'ERROR'} || (return undef)
MC/DC100%1/1
$self->{'ERROR'} || (return undef)
$self->{'ERROR'}
Truth table100%2/2
A
A= $self->{'ERROR'}
| |||||||||||||||||||||||||||||
| 213 | |||||||||||||||||||||||||||||
| 214 | 4 | ▶ | if (ref $handlers eq 'HASH') { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 215 | 3 | ▶ | if ($hkey = $$error->select_handler(keys %$handlers)) { | ||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||
| 216 | 1 | $handler = $handlers->{ $hkey }; | |||||||||||||||||||||||||||
| 217 | 1 | ▶ | $self->debug("using error handler for $hkey") if $self->{ DEBUG }; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 218 | } | ||||||||||||||||||||||||||||
| 219 | elsif ($handler = $handlers->{ default }) { | ||||||||||||||||||||||||||||
| 220 | # use default handler | ||||||||||||||||||||||||||||
| 221 | 2 | ▶ | $self->debug("using default error handler") if $self->{ DEBUG }; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 222 | } | ||||||||||||||||||||||||||||
| 223 | else { | ||||||||||||||||||||||||||||
| 224 | 0 | return undef; ## RETURN | |||||||||||||||||||||||||||
| 225 | } | ||||||||||||||||||||||||||||
| 226 | } | ||||||||||||||||||||||||||||
| 227 | else { | ||||||||||||||||||||||||||||
| 228 | 1 | $handler = $handlers; | |||||||||||||||||||||||||||
| 229 | 1 | ▶ | $self->debug("using default error handler") if $self->{ DEBUG }; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 230 | } | ||||||||||||||||||||||||||||
| 231 | |||||||||||||||||||||||||||||
| 232 | 4 | eval { $handler = $context->template($handler) }; | |||||||||||||||||||||||||||
| 233 | 4 | ▶ | if ($@) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 234 | 0 | $$error = $@; | |||||||||||||||||||||||||||
| 235 | 0 | return undef; ## RETURN | |||||||||||||||||||||||||||
| 236 | }; | ||||||||||||||||||||||||||||
| 237 | |||||||||||||||||||||||||||||
| 238 | 4 | $context->stash->set('error', $$error); | |||||||||||||||||||||||||||
| 239 | 4 | eval { | |||||||||||||||||||||||||||
| 240 | 4 | $output .= $context->process($handler); | |||||||||||||||||||||||||||
| 241 | }; | ||||||||||||||||||||||||||||
| 242 | 4 | ▶ | if ($@) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 243 | 0 | $$error = $@; | |||||||||||||||||||||||||||
| 244 | 0 | return undef; ## RETURN | |||||||||||||||||||||||||||
| 245 | } | ||||||||||||||||||||||||||||
| 246 | |||||||||||||||||||||||||||||
| 247 | 4 | return $output; | |||||||||||||||||||||||||||
| 248 | } | ||||||||||||||||||||||||||||
| 249 | |||||||||||||||||||||||||||||
| 250 | 116 | 1; | |||||||||||||||||||||||||||
| 251 | |||||||||||||||||||||||||||||
| 252 | __END__ | ||||||||||||||||||||||||||||