blib/lib/DTL/Fast/Tag/Include.pm

filter: Statementstmt 97.1% 34 / 35 Branchbran 75.0% 3 / 4 Conditioncond 25.0% 1 / 4 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 100% 8 / 8 Podpod 0.0% 0 / 3 totaltotal 82.1% 46 / 56 SCAR 16.2
CC
5
Cov
88%
render
3.6
new
3.0
BEGIN
1.0
CRAP 5.0
« blib/lib/DTL/Fast/Filter/Reverse.pm ↑ Summary blib/lib/DTL/Fast/Tag/Widthratio.pm »
1 package DTL::Fast::Tag::Include;
2 5 ▶use strict; use utf8; use warnings FATAL => 'all';
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
3 5 ▶use parent 'DTL::Fast::Tag::Simple';
Subroutine BEGIN: called CC=1 SCAR=0.0
4  
5 5 $DTL::Fast::TAG_HANDLERS{'include'} = __PACKAGE__;
6  
7 5 ▶use DTL::Fast::Expression;
Subroutine BEGIN: called CC=1 SCAR=0.0
8  
9 #@Override
10 sub new
11 {
12 17 ▶ my( $proto, $parameter, %kwargs ) = @_;
Subroutine new: called CC=3 SCAR=11.0
Pod undocumented
13 17 ▶ $parameter //= '';
Condition50%1/2
$parameter //= ""
l!l
170
MC/DC0%0/1
$parameter //= ""
$parameter
Truth table50%1/2
A
A= $parameter
Aresult
11
00
14  
15 17 my @parameter = split /\s+with\s+/, $parameter;
16
17 17 my $self = $proto->SUPER::new( $parameter[0], %kwargs );
18
19 17 ▶ if( scalar @parameter > 1 ) # with used
Branch: 1 branch
BranchTrueFalseTotal
if (scalar @parameter > 1) 1 16 17
20 {
21 1 $kwargs{'raw_chunks'} = [];
22 1 require DTL::Fast::Tag::With;
23 1 $self = DTL::Fast::Tag::With->new($parameter[1], %kwargs)->add_chunk($self);
24 }
25 17 return $self;
26 }
27  
28  
29 #@Override
30 sub parse_parameters
31 {
32 17 ▶ my $self = shift;
Subroutine parse_parameters: called CC=1 SCAR=0.0
Pod undocumented
33 17 $self->{'template'} = DTL::Fast::Expression->new($self->{'parameter'});
34 17 return $self;
35 }
36  
37 #@Override
38 sub render
39 {
40 21 ▶ my ($self, $context) = @_;
Subroutine render: called CC=3 SCAR=12.7
Pod undocumented
41
42 21 my $template_name = $self->{'template'}->render($context);
43
44 my $result = DTL::Fast::get_template(
45 $template_name
46 21 , 'dirs' => $self->{'dirs'}
47 );
48
49 die $self->get_render_error(
50 $context,
51 sprintf(
52 "Couldn't find included template %s in directories %s"
53 , $template_name // 'undef'
54 20 ▶ , join(', ', @{$self->{'dirs'}})
Branch: 1 branch
BranchTrueFalseTotal
unless defined $result 0 20 20
Condition0%0/2
$template_name // "undef"
l!l
00
MC/DC0%0/1
$template_name // "undef"
$template_name
Truth table0%0/2
A
A= $template_name
Aresult
11
00
55 )
56 ) if not defined $result;
57
58 20 return $result->render($context);
59 }
60  
61 5 1;
« blib/lib/DTL/Fast/Filter/Reverse.pm ↑ Summary blib/lib/DTL/Fast/Tag/Widthratio.pm »