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

filter: Statementstmt 92.5% 37 / 40 Branchbran 60.0% 6 / 10 Conditioncond 28.5% 2 / 7 MC/DCmcdc 0.0% 0 / 3 Subroutinesub 100% 7 / 7 Podpod 0.0% 0 / 2 totaltotal 75.3% 52 / 69 SCAR 23.9
CC
10
Cov
79%
render
11.7
parse_parameters
2.0
BEGIN
1.0
CRAP 10.9
« blib/lib/DTL/Fast/Expression/Operator/Binary/Pow.pm ↑ Summary blib/lib/DTL/Fast/Filter/Timesince.pm »
1 package DTL::Fast::Tag::Ssi;
2 2 ▶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 2 ▶use parent 'DTL::Fast::Tag::Simple';
Subroutine BEGIN: called CC=1 SCAR=0.0
4  
5 2 $DTL::Fast::TAG_HANDLERS{'ssi'} = __PACKAGE__;
6  
7 2 ▶use DTL::Fast::Expression;
Subroutine BEGIN: called CC=1 SCAR=0.0
8  
9 #@Override
10 sub parse_parameters
11 {
12 2 ▶ my $self = shift;
Subroutine parse_parameters: called CC=2 SCAR=7.1
Pod undocumented
13 2 ▶ if( $self->{'parameter'} =~ /^\s*(.+?)(?:\s*(parsed))?\s*$/ )
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{'parameter'} =~ /^\s*(.+?)(?:\s*(parsed))?\s*$/) { } 2 0 2
14 {
15 2 @{$self}{'template', 'parsed'} = (
16 DTL::Fast::Variable->new($1)
17 , $2
18 );
19 2 warn $self->get_parse_warning('`ssi` tag is now depricated and will be removed in future versions. Please, use `include` tag');
20 }
21 else
22 {
23 0 die $self->get_parse_error("can't parse parameter: $self->{'parameter'}");
24 }
25
26 2 return $self;
27 }
28  
29 #@Override
30 # @todo: recursion protection
31 sub render
32 {
33 2 ▶ my ($self, $context, $result) = @_;
Subroutine render: called CC=9 SCAR=24.6
Pod undocumented
34
35 2 my $ssi_dirs = $context->{'ns'}->[-1]->{'_dtl_ssi_dirs'};
36
37 2 ▶ if(
Branch: 1 branch
BranchTrueFalseTotal
if (defined $ssi_dirs and ref $ssi_dirs eq 'ARRAY' and scalar @$ssi_dirs) { } 2 0 2
Condition40%2/5
defined $ssi_dirs and ref $ssi_dirs eq "ARRAY" and scalar @$ssi_dirs
!ll
02
defined $ssi_dirs and ref $ssi_dirs eq "ARRAY"
!ll&&!rl&&r
002
MC/DC0%0/2
defined $ssi_dirs and ref $ssi_dirs eq "ARRAY" and scalar @$ssi_dirs
defined $ssi_dirs ref $ssi_dirs eq "ARRAY"
Truth table33%1/3
A and B
A= defined $ssi_dirsB= ref $ssi_dirs eq "ARRAY"
ABresult
0X0
100
111
38 defined $ssi_dirs
39 and ref $ssi_dirs eq 'ARRAY'
40 and scalar @$ssi_dirs
41 )
42 {
43 2 my $template_path = $self->{'template'}->render($context);
44
45 2 my $allowed = 0;
46
47 2 foreach my $allowed_dir (@$ssi_dirs)
48 {
49 2 ▶ if( $template_path =~ /^\Q$allowed_dir\E/s )
Branch: 1 branch
BranchTrueFalseTotal
if ($template_path =~ /^\Q$allowed_dir\E/s) 2 0 2
50 {
51 2 $allowed = 1;
52 2 last;
53 }
54 }
55  
56 2 ▶ if( $allowed )
Branch: 1 branch
BranchTrueFalseTotal
if ($allowed) { } 2 0 2
57 {
58 2 $result = DTL::Fast::__read_file($template_path);
59
60 2 ▶ if( $self->{'parsed'} )
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"parsed"}) 1 1 2
61 {
62 1 $result = DTL::Fast::Template->new($result)->render($context);
63 }
64 }
65 else
66 {
67 0 ▶ die $self-get_render_error(
Condition0%0/2
$template_path // "undef"
l!l
00
MC/DC0%0/1
$template_path // "undef"
$template_path
Truth table0%0/2
A
A= $template_path
Aresult
11
00
68 $context,
69 sprintf(
70 "File %s is not in one of ssi_dirs:\n\t%s"
71 , $template_path // 'undef'
72 , join( "\n\t", @$ssi_dirs )
73 )
74 );
75 }
76 }
77 else
78 {
79 0 die $self->get_render_error($context, 'in order to use ssi tag, you must provide ssi_dirs argument to the constructor');
80 }
81
82 2 return $result;
83 }
84  
85 2 1;
« blib/lib/DTL/Fast/Expression/Operator/Binary/Pow.pm ↑ Summary blib/lib/DTL/Fast/Filter/Timesince.pm »