| 1 | package Template::Recall::Base; | ||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||
| 3 | 4 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 4 | 4 | ▶ | no warnings; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 5 | |||||||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||||||
| 7 | 4 | our $VERSION='0.08'; | |||||||||||||||||||||||||||
| 8 | |||||||||||||||||||||||||||||
| 9 | |||||||||||||||||||||||||||||
| 10 | sub render { | ||||||||||||||||||||||||||||
| 11 | |||||||||||||||||||||||||||||
| 12 | 8 | ▶ | my ( $class, $template, $hash_ref, $delims ) = @_; | ||||||||||||||||||||||||||
|
Subroutine
render: called CC=8 SCAR=22.5
Pod
undocumented
| |||||||||||||||||||||||||||||
| 13 | |||||||||||||||||||||||||||||
| 14 | 8 | ▶ | if ( not defined ($template) ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 15 | 0 | die "Template::Recall::Base::render() 'template' parameter not present"; | |||||||||||||||||||||||||||
| 16 | } | ||||||||||||||||||||||||||||
| 17 | |||||||||||||||||||||||||||||
| 18 | 8 | ▶ | my $user_delims = ref $delims && $#{$delims} == 1 ? 1 : 0; | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
ref $delims and $#{$delims;} == 1
MC/DC0%0/2
ref $delims and $#{$delims;} == 1
ref $delims
$#{$delims;} == 1
Truth table33%1/3
A and B
A= ref $delimsB= $#{$delims;} == 1
| |||||||||||||||||||||||||||||
| 19 | |||||||||||||||||||||||||||||
| 20 | 8 | ▶ | if (ref $hash_ref) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 21 | |||||||||||||||||||||||||||||
| 22 | 8 | ▶ | while ( my ($key, $value) = each %$hash_ref) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 23 | 8 | ▶ | if ( $user_delims ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 24 | 8 | my $d = $delims->[0] . '\s*' . $key . '\s*' . $delims->[1]; | |||||||||||||||||||||||||||
| 25 | 8 | $template =~ s/$d/$value/g; | |||||||||||||||||||||||||||
| 26 | } | ||||||||||||||||||||||||||||
| 27 | else { # exactly specified delims | ||||||||||||||||||||||||||||
| 28 | 0 | $template =~ s/$key/$value/g; | |||||||||||||||||||||||||||
| 29 | } | ||||||||||||||||||||||||||||
| 30 | } # while | ||||||||||||||||||||||||||||
| 31 | |||||||||||||||||||||||||||||
| 32 | } # if | ||||||||||||||||||||||||||||
| 33 | |||||||||||||||||||||||||||||
| 34 | |||||||||||||||||||||||||||||
| 35 | # Do trimming, if so flagged | ||||||||||||||||||||||||||||
| 36 | 8 | ▶ | return trim($class->{'trim'}, $template) if defined $class->{'trim'}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 37 | |||||||||||||||||||||||||||||
| 38 | 4 | return $template; | |||||||||||||||||||||||||||
| 39 | |||||||||||||||||||||||||||||
| 40 | } # render() | ||||||||||||||||||||||||||||
| 41 | |||||||||||||||||||||||||||||
| 42 | |||||||||||||||||||||||||||||
| 43 | |||||||||||||||||||||||||||||
| 44 | |||||||||||||||||||||||||||||
| 45 | # Trim output if specified | ||||||||||||||||||||||||||||
| 46 | |||||||||||||||||||||||||||||
| 47 | sub trim { | ||||||||||||||||||||||||||||
| 48 | 4 | ▶ | my ($trim, $template) = @_; | ||||||||||||||||||||||||||
|
Subroutine
trim: called CC=8 SCAR=21.6
Pod
undocumented
| |||||||||||||||||||||||||||||
| 49 | |||||||||||||||||||||||||||||
| 50 | 4 | ▶ | return $template if !defined($trim); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 51 | |||||||||||||||||||||||||||||
| 52 | 4 | ▶ | if ($trim eq 'left' or $trim eq 'l') { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$trim eq "left" or $trim eq "l"
MC/DC50%1/2
$trim eq "left" or $trim eq "l"
$trim eq "left"
$trim eq "l"
Truth table66%2/3
A or B
A= $trim eq "left"B= $trim eq "l"
| |||||||||||||||||||||||||||||
| 53 | 1 | $template =~ s/^\s+//g; | |||||||||||||||||||||||||||
| 54 | 1 | return $template; | |||||||||||||||||||||||||||
| 55 | } | ||||||||||||||||||||||||||||
| 56 | |||||||||||||||||||||||||||||
| 57 | 3 | ▶ | if ($trim eq 'right' or $trim eq 'r') { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$trim eq "right" or $trim eq "r"
MC/DC50%1/2
$trim eq "right" or $trim eq "r"
$trim eq "right"
$trim eq "r"
Truth table66%2/3
A or B
A= $trim eq "right"B= $trim eq "r"
| |||||||||||||||||||||||||||||
| 58 | 1 | $template =~ s/\s+$//g; | |||||||||||||||||||||||||||
| 59 | 1 | return $template; | |||||||||||||||||||||||||||
| 60 | } | ||||||||||||||||||||||||||||
| 61 | |||||||||||||||||||||||||||||
| 62 | 2 | ▶ | if ($trim eq 'both' or $trim eq 'b') { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$trim eq "both" or $trim eq "b"
MC/DC0%0/2
$trim eq "both" or $trim eq "b"
$trim eq "both"
$trim eq "b"
Truth table33%1/3
A or B
A= $trim eq "both"B= $trim eq "b"
| |||||||||||||||||||||||||||||
| 63 | 2 | $template =~ s/^\s+|\s+$//g; | |||||||||||||||||||||||||||
| 64 | 2 | return $template; | |||||||||||||||||||||||||||
| 65 | } | ||||||||||||||||||||||||||||
| 66 | |||||||||||||||||||||||||||||
| 67 | } # trim() | ||||||||||||||||||||||||||||
| 68 | |||||||||||||||||||||||||||||
| 69 | 4 | 1; | |||||||||||||||||||||||||||