line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Template::Recall::Base;
|
2
|
|
|
|
|
|
|
|
3
|
6
|
|
|
6
|
|
29
|
use strict;
|
|
6
|
|
|
|
|
6
|
|
|
6
|
|
|
|
|
207
|
|
4
|
6
|
|
|
6
|
|
20
|
no warnings;
|
|
6
|
|
|
|
|
9
|
|
|
6
|
|
|
|
|
1790
|
|
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
our $VERSION='0.07';
|
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
sub render {
|
11
|
|
|
|
|
|
|
|
12
|
12
|
|
|
12
|
0
|
20
|
my ( $class, $template, $hash_ref, $delims ) = @_;
|
13
|
|
|
|
|
|
|
|
14
|
12
|
50
|
|
|
|
51
|
if ( not defined ($template) ) {
|
15
|
0
|
|
|
|
|
0
|
return "Template::Recall::Base::render() 'template' parameter not present";
|
16
|
|
|
|
|
|
|
}
|
17
|
|
|
|
|
|
|
|
18
|
12
|
50
|
33
|
|
|
37
|
my $user_delims = ref($delims) && $#{$delims} == 1 ? 1 : 0;
|
19
|
12
|
100
|
|
|
|
56
|
if ( ref($hash_ref) ) {
|
20
|
|
|
|
|
|
|
|
21
|
11
|
|
|
|
|
48
|
while ( my ($key, $value) = each %$hash_ref) {
|
22
|
11
|
50
|
|
|
|
20
|
if ( $user_delims ) {
|
23
|
11
|
|
|
|
|
32
|
my $d = $delims->[0] . '\s*' . $key . '\s*' . $delims->[1];
|
24
|
11
|
|
|
|
|
179
|
$template =~ s/$d/$value/g;
|
25
|
|
|
|
|
|
|
}
|
26
|
|
|
|
|
|
|
else { # exactly specified delims
|
27
|
0
|
|
|
|
|
0
|
$template =~ s/$key/$value/g;
|
28
|
|
|
|
|
|
|
}
|
29
|
|
|
|
|
|
|
} # while
|
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
} # if
|
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
# Do trimming, if so flagged
|
35
|
12
|
100
|
|
|
|
32
|
return trim($class->{'trim'}, $template) if defined($class->{'trim'});
|
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
|
38
|
8
|
|
|
|
|
423
|
return $template;
|
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
} # render()
|
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
# Trim output if directed to do so
|
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
sub trim {
|
48
|
4
|
|
|
4
|
0
|
6
|
my ($trim, $template) = @_;
|
49
|
|
|
|
|
|
|
|
50
|
4
|
50
|
|
|
|
13
|
return $template if !defined($trim);
|
51
|
|
|
|
|
|
|
|
52
|
4
|
100
|
66
|
|
|
425
|
if ($trim eq 'left' or $trim eq 'l') {
|
53
|
1
|
|
|
|
|
4
|
$template =~ s/^\s+//g;
|
54
|
1
|
|
|
|
|
4
|
return $template;
|
55
|
|
|
|
|
|
|
}
|
56
|
|
|
|
|
|
|
|
57
|
3
|
100
|
66
|
|
|
10
|
if ($trim eq 'right' or $trim eq 'r') {
|
58
|
1
|
|
|
|
|
5
|
$template =~ s/\s+$//g;
|
59
|
1
|
|
|
|
|
4
|
return $template;
|
60
|
|
|
|
|
|
|
}
|
61
|
|
|
|
|
|
|
|
62
|
2
|
50
|
33
|
|
|
7
|
if ($trim eq 'both' or $trim eq 'b') {
|
63
|
2
|
|
|
|
|
10
|
$template =~ s/^\s+|\s+$//g;
|
64
|
2
|
|
|
|
|
10
|
return $template;
|
65
|
|
|
|
|
|
|
}
|
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
} # trim()
|
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
1;
|