Extension/CSTART.pm

filter: Statementstmt 73.5% 25 / 34 Branchbran 60.0% 6 / 10 Conditioncond 33.3% 1 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 75.0% 6 / 8 Podpod 0.0% 0 / 3 totaltotal 63.3% 38 / 60 CC 7 SCAR 10.4
CC
7
Cov
68%
_ecp_cstart
6.0
init
3.1
_cstart
3.0
CRAP 2.8
« Extension/HEAD_BODY.pm ↑ Summary Extension/SLASH_VAR.pm »
1 package HTML::Template::Pro::Extension::CSTART;
2  
3 1 $VERSION = "0.11";
4 0 ▶sub Version { $VERSION; }
Subroutine Version: not called CC=1 SCAR=6.9
Pod undocumented
5  
6 1 ▶use Carp;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
8  
9 1 my %fields_parent =
10 (
11 ecp_compatibility_mode => 0,
12 );
13
14 1 my $re_var = q{
15 <\s*
16 [Tt][Mm][Pp][Ll]_[Cc][Ss][Tt][Aa][Rr][Tt]
17 \s*>
18 (.*?)
19 <\s*\/[Tt][Mm][Pp][Ll]_[Cc][Ss][Tt][Aa][Rr][Tt]\s*>};
20  
21  
22 1 ▶sub init {
Subroutine init: called CC=3 SCAR=11.4
Pod undocumented
23 1 my $self = shift;
24 1 ▶ while (my ($key,$val) = each(%fields_parent)) {
Branch: 1 branch
BranchTrueFalseTotal
if (() = each %fields_parent) 1 1 2
25 1 ▶ $self->{$key} = $self->{$key} || $val;
Condition33%1/3
$self->{$key} || $val
l!l&&r!l&&!r
001
MC/DC0%0/2
$self->{$key} || $val
$self->{$key} $val
Truth table33%1/3
A || B
A= $self->{$key}B= $val
ABresult
1X1
011
000
26 }
27 }
28  
29 1 ▶sub get_filter {
Subroutine get_filter: called CC=1 SCAR=0.0
Pod undocumented
30 1 my $self = shift;
31 1 return _get_filter($self);
32 }
33  
34 1 ▶sub _get_filter {
Subroutine _get_filter: called CC=2 SCAR=7.0
35 1 my $self = shift;
36 1 my @ret ;
37 # Sorry for this :->. I've an e-commerce project called ecp that
38 # use a CSTART modified syntax using html comment
39 1 ▶ push @ret,\&_ecp_cstart if ($self->{ecp_compatibility_mode});
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"ecp_compatibility_mode"} 0 1 1
40 # Standard CSTART syntax
41 1 push @ret,\&_cstart;
42 1 return @ret;
43 }
44  
45  
46 # funzione filtro per aggiungere il tag <TMPL_CSTART>
47 # da tenere fintanto che la nostra patch non sia inserita nella
48 # distribuzione standard del modulo
49 1 ▶sub _cstart {
Subroutine _cstart: called CC=3 SCAR=11.0
50 1 my $template = shift;
51 1 my $ret = '';
52 1 ▶ while ($$template =~m{$re_var}xsg) {
Branch: 1 branch
BranchTrueFalseTotal
if ($$template =~ /$re_var/gsx) 2 1 3
53 2 $ret .= $1;
54 }
55 1 ▶ $$template = $ret eq '' ? $$template : $ret;
Branch: 1 branch
BranchTrueFalseTotal
$ret eq '' ? : 0 1 1
56 }
57  
58 0 ▶sub _ecp_cstart {
Subroutine _ecp_cstart: not called CC=2 SCAR=17.9
59 0 my $template = shift;
60 0 my $brem ='<!' . '--';
61 0 my $eend ='--' . '>';
62 0 my $start = qq=$brem\\s*[Cc][Ss][Tt][Aa][Rr][Tt]\\s*$eend=;
63 0 my $end = qq=$brem\\s*[Cc][Ee][Nn][Dd]\\s*$eend=;
64 0 ▶ if ($$template =~/$end/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($$template =~ /$end/) 0 0 0
65 0 $$template =~s|$start|<TMPL_CSTART>|g;
66 0 $$template =~s|$end|</TMPL_CSTART>|g;
67 }
68 }
69  
70  
71  
72 1 1;
« Extension/HEAD_BODY.pm ↑ Summary Extension/SLASH_VAR.pm »