TemplateToolkit.pm

filter: Statementstmt 97.5% 199 / 204 Branchbran 88.5% 85 / 96 Conditioncond 74.5% 38 / 51 MC/DCmcdc 46.6% 14 / 30 Subroutinesub 100% 27 / 27 Podpod 100% 5 / 5 totaltotal 89.1% 368 / 413 CC 74 SCAR 24.0
CC
74
Cov
92%
_handle_template
17.2
prepare_app
16.2
process_error
15.1
CRAP 11.0
↑ Summary Debug/TemplateToolkit.pm »
1 package Plack::Middleware::TemplateToolkit;
2 # ABSTRACT: Serve files with Template Toolkit and Plack
3 7 $Plack::Middleware::TemplateToolkit::VERSION = '0.28';
4 7 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 7 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 7 ▶use 5.008_001;
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 7 ▶use parent 'Exporter'; # for 'use Plack::Middleware::TemplateToolkit $version;'
Subroutine BEGIN: called CC=1 SCAR=0.0
9 7 ▶use parent 'Plack::Middleware';
Subroutine BEGIN: called CC=1 SCAR=0.0
10 7 ▶use Plack::Request 0.994;
Subroutine BEGIN: called CC=1 SCAR=0.0
11 7 ▶use Plack::MIME;
Subroutine BEGIN: called CC=1 SCAR=0.0
12 7 ▶use Template 2;
Subroutine BEGIN: called CC=1 SCAR=0.0
13 7 ▶use Scalar::Util qw(blessed);
Subroutine BEGIN: called CC=1 SCAR=0.0
14 7 ▶use HTTP::Status qw(status_message);
Subroutine BEGIN: called CC=1 SCAR=0.0
15 7 ▶use Time::HiRes;
Subroutine BEGIN: called CC=1 SCAR=0.0
16 7 ▶use Plack::Middleware::Debug::Timer;
Subroutine BEGIN: called CC=1 SCAR=0.0
17 7 ▶use Encode;
Subroutine BEGIN: called CC=1 SCAR=0.0
18 7 ▶use Carp;
Subroutine BEGIN: called CC=1 SCAR=0.0
19  
20 # Configuration options as described in Template::Manual::Config
21 7 our @TT_CONFIG;
22 7 our @DEPRECATED;
23  
24 7 ▶BEGIN {
Subroutine BEGIN: called CC=2 SCAR=6.9
25 7 @TT_CONFIG = qw(ENCODING START_TAG END_TAG OUTLINE_TAG TAG_STYLE PRE_CHOMP POST_CHOMP TRIM
26 INTERPOLATE ANYCASE INCLUDE_PATH DELIMITER ABSOLUTE RELATIVE DEFAULT
27 BLOCKS VIEWS AUTO_RESET RECURSION VARIABLES CONSTANTS
28 CONSTANT_NAMESPACE NAMESPACE PRE_PROCESS POST_PROCESS PROCESS WRAPPER
29 ERROR EVAL_PERL OUTPUT OUTPUT_PATH STRICT DEBUG DEBUG_FORMAT
30 CACHE_SIZE STAT_TTL COMPILE_EXT COMPILE_DIR PLUGINS PLUGIN_BASE
31 LOAD_PERL FILTERS LOAD_TEMPLATES LOAD_PLUGINS LOAD_FILTERS
32 TOLERANT SERVICE CONTEXT STASH PARSER GRAMMAR
33 );
34  
35 # the following ugly code is only needed to catch deprecated accessors
36 7 @DEPRECATED = qw(pre_process process eval_perl interpolate post_chomp);
37 7 ▶ no strict 'refs';
Subroutine BEGIN: called CC=1 SCAR=0.0
38 7 my $module = "Plack::Middleware::TemplateToolkit";
39 7 foreach my $name (@DEPRECATED) {
40 35 ▶ *{ $module . "::$name" } = sub {
Subroutine __ANON__: called CC=1 SCAR=0.0
41 2 my $correct = uc($name);
42 2 carp $module. "$name is deprecated, use ::$correct";
43 2 my $method = $module . "::$correct";
44 2 &$method(@_);
45 }
46 35 }
47  
48 21 ▶ sub new {
Subroutine new: called CC=4 SCAR=14.1
Pod documented
49 21 my $self = Plack::Component::new(@_);
50  
51 # Support 'root' config (matches MW::Static etc)
52 # if INCLUDE_PATH hasn't been defined
53 21 ▶ $self->INCLUDE_PATH( $self->root )
Branch: 1 branch
BranchTrueFalseTotal
if not $self->INCLUDE_PATH and $self->root 0 21 21
Condition66%2/3
not $self->INCLUDE_PATH and $self->root
!ll&&!rl&&r
2010
MC/DC0%0/2
not $self->INCLUDE_PATH and $self->root
not $self->INCLUDE_PATH $self->root
Truth table66%2/3
not(A) and B
A= not $self->INCLUDE_PATHB= $self->root
ABresult
0X0
100
111
54 if !$self->INCLUDE_PATH() && $self->root;
55  
56 21 foreach ( grep { defined $self->{$_} } @DEPRECATED ) {
57 1 $self->$_;
58 }
59 21 $self;
60 }
61 }
62  
63 7 ▶use Plack::Util::Accessor (
Subroutine BEGIN: called CC=1 SCAR=0.0
64 7 qw(dir_index path extension content_type default_type tt root timer
65 pass_through decode_request encode_response vars request_vars),
66 @TT_CONFIG
67 7 );
68  
69 35 ▶sub prepare_app {
Subroutine prepare_app: called CC=16 SCAR=27.9
Pod documented
70 35 my ($self) = @_;
71  
72 35 ▶ $self->dir_index('index.html') unless $self->dir_index;
Branch: 1 branch
BranchTrueFalseTotal
unless $self->dir_index 19 16 35
73 35 ▶ $self->pass_through(0) unless defined $self->pass_through;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $self->pass_through 18 17 35
74 35 ▶ $self->default_type('text/html') unless $self->default_type;
Branch: 1 branch
BranchTrueFalseTotal
unless $self->default_type 17 18 35
75 35 ▶ $self->decode_request('utf8') unless defined $self->decode_request;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $self->decode_request 19 16 35
76 35 ▶ $self->encode_response('utf8') unless defined $self->encode_response;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $self->encode_response 18 17 35
77 35 ▶ $self->request_vars( [] ) unless defined $self->request_vars;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $self->request_vars 16 19 35
78  
79 35 ▶ if ( not $self->vars ) {
Branch: 3 branches
BranchTrueFalseTotal
if (not $self->vars) { } 17 18 35
elsif (ref $self->vars eq 'HASH') { } 1 17 18
elsif (ref $self->vars ne 'CODE') { } 0 17 17
80 17 ▶ $self->vars( sub { return { params => shift->query_parameters } } );
Subroutine __ANON__: called CC=1 SCAR=0.0
81 } elsif ( ref $self->vars eq 'HASH' ) {
82 1 my $vars = $self->vars;
83 1 ▶ $self->vars( sub { return $vars; } );
Subroutine __ANON__: called CC=1 SCAR=0.0
84 } elsif ( ref $self->vars ne 'CODE' ) {
85 0 die 'vars must be a code or hash reference, if defined';
86 }
87  
88 35 my $config = {};
89 35 foreach (@TT_CONFIG) {
90 1785 ▶ next unless $self->$_;
Branch: 1 branch
BranchTrueFalseTotal
unless $self->$_ 1755 30 1785
91 30 $config->{$_} = $self->$_;
92 30 $self->$_(undef); # don't initialize twice
93 }
94  
95 35 ▶ if ( $self->tt ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->tt) { } 17 18 35
96 17 ▶ die 'tt must be a Template instance'
Branch: 1 branch
BranchTrueFalseTotal
unless UNIVERSAL::isa($self->tt, "Template") 0 17 17
97 unless UNIVERSAL::isa( $self->tt, 'Template' );
98 17 ▶ die 'Either specify a template with tt or Template options, not both'
Branch: 1 branch
BranchTrueFalseTotal
if %$config 0 17 17
99 if %$config;
100 } else {
101 18 ▶ die 'No INCLUDE_PATH supplied' unless $config->{INCLUDE_PATH};
Branch: 1 branch
BranchTrueFalseTotal
unless $config->{"INCLUDE_PATH"} 0 18 18
102 18 $self->tt( Template->new($config) );
103 }
104 }
105  
106 45 ▶sub call { # adapted from Plack::Middleware::Static
Subroutine call: called CC=7 SCAR=20.1
Pod documented
107 45 my ( $self, $env ) = @_;
108  
109 45 ▶ my $start = [ Time::HiRes::gettimeofday ] if $self->timer;
Branch: 1 branch
BranchTrueFalseTotal
if $self->timer 0 45 45
110 45 my $res = $self->_handle_template($env);
111  
112 45 ▶ if ( !$res or ( $self->pass_through and $res->[0] == 404 ) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (not $res or $self->pass_through and $res->[0] == 404) 4 41 45
Condition100%6/6
not $res or $self->pass_through and $res->[0] == 404
l!l&&r!l&&!r
3141
$self->pass_through and $res->[0] == 404
!ll&&!rl&&r
3921
MC/DC100%3/3
not $res or $self->pass_through and $res->[0] == 404
not $res $self->pass_through $res->[0] == 404
Truth table100%4/4
not(A) or B and C
A= not $resB= $self->pass_throughC= $res->[0] == 404
ABCresult
1XX1
0111
00X0
0100
113 4 ▶ if ( $self->app ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->app) { } 1 3 4
114 # pass to the next middleware/app
115 1 $res = $self->app->($env);
116 # if ( $self->catch_errors and $res->[0] =~ /^[45]/ ) {
117 # TODO: process error message (but better use callback)
118 # }
119 } else {
120 3 my $req = Plack::Request->new($env);
121 3 $res = $self->process_error( 404, 'Not found', 'text/plain', $req );
122 }
123 }
124  
125 45 ▶ if ($self->timer) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->timer) 0 45 45
126 0 my $end = [ Time::HiRes::gettimeofday ];
127 0 $env->{'tt.start'} = Plack::Middleware::Debug::Timer->format_time($start);
128 0 $env->{'tt.end'} = Plack::Middleware::Debug::Timer->format_time($end);
129 0 $env->{'tt.elapsed'}
130 = sprintf '%.6f s', Time::HiRes::tv_interval $start, $end;
131 }
132  
133 45 $res;
134 }
135  
136 51 ▶sub process_template {
Subroutine process_template: called CC=6 SCAR=18.0
Pod documented
137 51 my ( $self, $template, $code, $vars ) = @_;
138  
139 51 my ( $content, $res );
140 51 ▶ if ( $self->tt->process( $template, $vars, \$content ) ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->tt->process($template, $vars, \$content)) { } 38 13 51
141 38 ▶ my $type = $self->content_type || do {
Condition66%4/6
$self->content_type || do { 'Plack::MIME'->mime_type($1) if $template =~ /(\.\w{1,6})$/ } || $self->default_type
l!l&&r!l&&!r
3620
$self->content_type or do { "Plack::MIME"->mime_type($1) if $template =~ /(\.\w{1,6})$/ }
l!l&&r!l&&!r
0362
MC/DC0%0/3
$self->content_type || do { 'Plack::MIME'->mime_type($1) if $template =~ /(\.\w{1,6})$/ } || $self->default_type
$self->content_type do { "Plack::MIME"->mime_type($1) if $template =~ /(\.\w{1,6})$/ } $self->default_type
Truth table50%2/4
A or B || C
A= $self->content_typeB= do { "Plack::MIME"->mime_type($1) if $template =~ /(\.\w{1,6})$/ }C= $self->default_type
ABCresult
1XX1
01X1
0011
0000
142 38 ▶ Plack::MIME->mime_type($1) if $template =~ /(\.\w{1,6})$/;
Branch: 1 branch
BranchTrueFalseTotal
if $template =~ /(\.\w{1,6})$/ 36 2 38
143 }
144 || $self->default_type;
145 38 ▶ if ( $self->encode_response ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->encode_response) 37 1 38
146 37 $content = encode( $self->encode_response, $content );
147 }
148 38 $res = [ $code, [ 'Content-Type' => $type ], [$content] ];
149 } else {
150 13 $res = $self->tt->error->as_string;
151 }
152  
153 51 return $res;
154 }
155  
156 24 ▶sub process_error {
Subroutine process_error: called CC=15 SCAR=27.1
Pod documented
157 24 my ( $self, $code, $error, $type, $req ) = @_;
158  
159 24 ▶ $code = 500 unless $code && $code =~ /^\d\d\d$/;
Branch: 1 branch
BranchTrueFalseTotal
unless $code and $code =~ /^\d\d\d$/ 4 20 24
Condition66%2/3
$code and $code =~ /^\d\d\d$/
!ll&&!rl&&r
4020
MC/DC50%1/2
$code and $code =~ /^\d\d\d$/
$code $code =~ /^\d\d\d$/
Truth table66%2/3
A and B
A= $codeB= $code =~ /^\d\d\d$/
ABresult
0X0
100
111
160 24 ▶ $error = status_message($code) unless $error;
Branch: 1 branch
BranchTrueFalseTotal
unless $error 6 18 24
161 24 ▶ $type = ( $self->content_type || $self->default_type || 'text/plain' )
Branch: 1 branch
BranchTrueFalseTotal
unless $type 6 18 24
Condition80%4/5
$self->content_type || $self->default_type || 'text/plain'
l!l
42
$self->content_type or $self->default_type
l!l&&r!l&&!r
042
MC/DC50%1/2
$self->content_type || $self->default_type || 'text/plain'
$self->content_type $self->default_type
Truth table66%2/3
A or B
A= $self->content_typeB= $self->default_type
ABresult
1X1
011
000
162 unless $type;
163  
164 # plain error without template
165 return [ $code, [ 'Content-Type' => $type ], [$error] ]
166 24 ▶ unless $self->{$code} and $self->tt;
Branch: 1 branch
BranchTrueFalseTotal
unless $self->{$code} and $self->tt 12 12 24
Condition100%3/3
$self->{$code} and $self->tt
!ll&&!rl&&r
10212
MC/DC100%2/2
$self->{$code} and $self->tt
$self->{$code} $self->tt
Truth table100%3/3
A and B
A= $self->{$code}B= $self->tt
ABresult
0X0
100
111
167  
168 12 ▶ $req = Plack::Request->new( { 'tt.vars' => {} } )
Branch: 1 branch
BranchTrueFalseTotal
unless builtin::blessed($req) and $req->isa("Plack::Request") 4 8 12
Condition66%2/3
builtin::blessed($req) and $req->isa("Plack::Request")
!ll&&!rl&&r
408
MC/DC50%1/2
builtin::blessed($req) and $req->isa("Plack::Request")
builtin::blessed($req) $req->isa("Plack::Request")
Truth table66%2/3
A and B
A= builtin::blessed($req)B= $req->isa("Plack::Request")
ABresult
0X0
100
111
169 unless blessed $req && $req->isa('Plack::Request');
170 12 eval { $self->_set_vars($req); };
171  
172 12 $req->env->{'tt.vars'}->{'error'} = $error;
173 12 $req->env->{'tt.vars'}->{'path'} = $req->path_info;
174 12 $req->env->{'tt.vars'}->{'request'} = $req;
175  
176 12 my $tpl = $self->{$code};
177 12 my $res = $self->process_template( $tpl, $code, $req->env->{'tt.vars'} );
178  
179 12 ▶ unless ( ref $res ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (ref $res) 4 8 12
180  
181 # processing error document failed: result in a 500 error
182 4 ▶ if ( $code eq 500 ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($code eq 500) { } 2 2 4
183 2 $res = [ 500, [ 'Content-Type' => $type ], [$res] ];
184 2 $tpl = undef;
185 } else {
186 2 ▶ if ( ref $req->logger ) {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $req->logger) 2 0 2
187 2 $req->logger->( { level => 'warn', message => $res } );
188 }
189 2 ( $res, $tpl ) = $self->process_error( 500, $res, $type, $req );
190 }
191 }
192  
193 12 ▶ return wantarray ? ( $res, $tpl ) : $res;
Branch: 1 branch
BranchTrueFalseTotal
wantarray ? : 10 2 12
194 }
195  
196 53 ▶sub _set_vars {
Subroutine _set_vars: called CC=14 SCAR=26.5
197 53 my ( $self, $req ) = @_;
198 53 my $env = $req->env;
199  
200 # we must not copy the vars by reference because
201 # otherwise we might modify the same object
202 53 ▶ my (%vars) = %{ $self->vars->($req) } if defined $self->vars;
Branch: 1 branch
BranchTrueFalseTotal
if defined $self->vars 53 0 53
203  
204 51 my $rv = $self->request_vars;
205 51 ▶ unless ( exists $vars{request} ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (exists $vars{"request"}) 50 1 51
206 50 ▶ if ( $rv eq 'all' ) {
Branch: 2 branches
BranchTrueFalseTotal
if ($rv eq 'all') { } 1 49 50
elsif (ref $rv and @$rv) { } 4 45 49
207 1 $vars{request} = $req;
208 ▶ } elsif ( ref $rv and @$rv ) {
Condition66%2/3
ref $rv and @$rv
!ll&&!rl&&r
0454
MC/DC50%1/2
ref $rv and @$rv
ref $rv @$rv
Truth table66%2/3
A and B
A= ref $rvB= @$rv
ABresult
0X0
100
111
209 4 $vars{request} = {};
210 4 foreach ( @{ $self->request_vars } ) {
211 8 ▶ next unless $req->can($_);
Branch: 1 branch
BranchTrueFalseTotal
unless $req->can($_) 2 6 8
212 6 my $value = $req->$_;
213  
214 # request vars should also be byte strings, so we must decode it
215 6 ▶ if ( $self->decode_request ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->decode_request) 6 0 6
216 6 my $encoding = $self->decode_request;
217  
218 6 ▶ if ( blessed($value) and $value->isa('Hash::MultiValue') )
Branch: 1 branch
BranchTrueFalseTotal
if (builtin::blessed($value) and $value->isa('Hash::MultiValue')) { } 4 2 6
Condition66%2/3
builtin::blessed($value) and $value->isa("Hash::MultiValue")
!ll&&!rl&&r
204
MC/DC50%1/2
builtin::blessed($value) and $value->isa("Hash::MultiValue")
builtin::blessed($value) $value->isa("Hash::MultiValue")
Truth table66%2/3
A and B
A= builtin::blessed($value)B= $value->isa("Hash::MultiValue")
ABresult
0X0
100
111
219 {
220 4 my @values = $value->values;
221 4 @values = map { decode( $encoding, $_ ) } @values;
222 4 my $hash = Hash::MultiValue->new;
223 4 foreach my $key ( $value->keys ) {
224 4 $key = decode( $encoding, $key );
225 4 $hash->add( $key, shift @values );
226 }
227 4 $value = $hash;
228 } else {
229 2 $value = decode( $encoding, $value );
230 }
231 }
232  
233 6 $vars{request}->{$_} = $value;
234 }
235 }
236 }
237  
238 51 ▶ if ( $env->{'tt.vars'} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($env->{'tt.vars'}) { } 14 37 51
239 # add to existing vars
240 14 foreach ( keys %vars ) {
241 14 $env->{'tt.vars'}->{$_} = $vars{$_};
242 }
243 } else {
244 37 $env->{'tt.vars'} = \%vars;
245 }
246 }
247  
248 # core function called once in 'call'
249 45 ▶sub _handle_template {
Subroutine _handle_template: called CC=17 SCAR=28.4
250 45 my ( $self, $env ) = @_;
251  
252 45 ▶ if ( not $env->{'tt.template'} ) {
Branch: 1 branch
BranchTrueFalseTotal
if (not $env->{'tt.template'}) { } 43 2 45
253 43 ▶ my $path = $env->{'tt.path'} || do {
Condition66%2/3
$env->{'tt.path'} || do { $env->{'tt.path'} = $env->{'PATH_INFO'} || '/' }
l!l&&r!l&&!r
1420
MC/DC0%0/2
$env->{'tt.path'} || do { $env->{'tt.path'} = $env->{'PATH_INFO'} || '/' }
$env->{'tt.path'} do { $env->{'tt.path'} = $env->{'PATH_INFO'} || '/' }
Truth table66%2/3
A || B
A= $env->{'tt.path'}B= do { $env->{'tt.path'} = $env->{'PATH_INFO'} || '/' }
ABresult
1X1
011
000
254 42 ▶ $env->{'tt.path'} = $env->{PATH_INFO} || '/';
Condition100%2/2
$env->{'PATH_INFO'} || '/'
l!l
411
MC/DC100%1/1
$env->{'PATH_INFO'} || '/'
$env->{'PATH_INFO'}
Truth table100%2/2
A
A= $env->{'PATH_INFO'}
Aresult
11
00
255 };
256  
257 43 ▶ my $path_match = $self->path || '/';
Condition100%2/2
$self->path || '/'
l!l
736
MC/DC100%1/1
$self->path || '/'
$self->path
Truth table100%2/2
A
A= $self->path
Aresult
11
00
258 43 for ($path) {
259 43 ▶ my $matched
Branch: 1 branch
BranchTrueFalseTotal
'CODE' eq ref $path_match ? : 2 41 43
260 = 'CODE' eq ref $path_match
261 ? $path_match->($_)
262 : $_ =~ $path_match;
263 43 ▶ if (not $matched) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($matched) 3 40 43
264 3 delete $env->{'tt.path'};
265 3 return;
266 }
267 }
268  
269 40 ▶ $path .= $self->dir_index if $path =~ /\/$/;
Branch: 1 branch
BranchTrueFalseTotal
if $path =~ m[/$] 4 36 40
270 40 $path =~ s{^/}{}; # Do not want to enable absolute paths
271  
272 40 my $extension = $self->extension;
273 40 ▶ if ( $extension and $path !~ /${extension}$/ ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($extension and not $path =~ /$extension$/) 1 39 40
Condition100%3/3
$extension and not $path =~ /$extension$/
!ll&&!rl&&r
3811
MC/DC100%2/2
$extension and not $path =~ /$extension$/
$extension not $path =~ /$extension$/
Truth table100%3/3
A and not(B)
A= $extensionB= not $path =~ /$extension$/
ABresult
0X0
100
111
274 # This 404 will be catched in method call if pass_through is set
275 1 my ($res, $tpl) = $self->process_error(
276 404, 'Not found', 'text/plain', Plack::Request->new($env) );
277 1 $env->{'tt.template'} = $tpl;
278 1 return $res;
279 }
280  
281 39 $env->{'tt.template'} = $path;
282 } else {
283 2 delete $env->{'tt.path'};
284 }
285  
286 41 my ($res, $tpl);
287 41 my $req = Plack::Request->new($env);
288 41 eval { $self->_set_vars($req); };
289 41 ▶ if ( $@ ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($@) { } 2 39 41
290 2 my $error = "error setting template variables: $@";
291 2 ▶ my $type = $self->content_type || $self->default_type;
Condition33%1/3
$self->content_type || $self->default_type
l!l&&r!l&&!r
020
MC/DC0%0/2
$self->content_type || $self->default_type
$self->content_type $self->default_type
Truth table33%1/3
A || B
A= $self->content_typeB= $self->default_type
ABresult
1X1
011
000
292 2 ( $res, $tpl ) = $self->process_error( 500, $error, $type, $req );
293 2 $env->{'tt.template'} = $tpl;
294 } else {
295 $res = $self->process_template(
296 39 $env->{'tt.template'}, 200, $env->{'tt.vars'} );
297 }
298  
299 41 ▶ unless ( ref $res ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (ref $res) 9 32 41
300 9 ▶ my $type = $self->content_type || $self->default_type;
Condition33%1/3
$self->content_type || $self->default_type
l!l&&r!l&&!r
090
MC/DC0%0/2
$self->content_type || $self->default_type
$self->content_type $self->default_type
Truth table33%1/3
A || B
A= $self->content_typeB= $self->default_type
ABresult
1X1
011
000
301 9 ▶ if ( $res =~ /file error .+ not found/ ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($res =~ /file error .+ not found/) { } 6 3 9
302 6 ( $res, $tpl ) = $self->process_error( 404, $res, $type, $req );
303 } else {
304 3 ▶ if ( ref $req->logger ) {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $req->logger) 3 0 3
305 3 $req->logger->( { level => 'warn', message => $res } );
306 }
307 3 ( $res, $tpl ) = $self->process_error( 500, $res, $type, $req );
308 }
309 9 $env->{'tt.template'} = $tpl;
310 }
311  
312 41 return $res;
313 }
314  
315 7 1;
316  
317 __END__
↑ Summary Debug/TemplateToolkit.pm »