| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package Amazon::API::Template; |
|
2
|
|
|
|
|
|
|
|
|
3
|
4
|
|
|
4
|
|
776
|
use strict; |
|
|
4
|
|
|
|
|
9
|
|
|
|
4
|
|
|
|
|
115
|
|
|
4
|
4
|
|
|
4
|
|
20
|
use warnings; |
|
|
4
|
|
|
|
|
7
|
|
|
|
4
|
|
|
|
|
139
|
|
|
5
|
|
|
|
|
|
|
|
|
6
|
4
|
|
|
4
|
|
472
|
use parent qw( Exporter ); |
|
|
4
|
|
|
|
|
307
|
|
|
|
4
|
|
|
|
|
35
|
|
|
7
|
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
our @EXPORT_OK |
|
9
|
|
|
|
|
|
|
= qw( to_template_var fetch_template render_template html2pod ); |
|
10
|
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
our %EXPORT_TAGS = ( all => [@EXPORT_OK] ); |
|
12
|
|
|
|
|
|
|
|
|
13
|
4
|
|
|
4
|
|
790
|
use Amazon::API::Constants qw(:chars :booleans); |
|
|
4
|
|
|
|
|
8
|
|
|
|
4
|
|
|
|
|
801
|
|
|
14
|
|
|
|
|
|
|
|
|
15
|
4
|
|
|
4
|
|
31
|
use ReadonlyX; |
|
|
4
|
|
|
|
|
10
|
|
|
|
4
|
|
|
|
|
208
|
|
|
16
|
4
|
|
|
4
|
|
2569
|
use Pod::HTML2Pod; |
|
|
4
|
|
|
|
|
173221
|
|
|
|
4
|
|
|
|
|
61
|
|
|
17
|
4
|
|
|
4
|
|
851
|
use English qw(-no_match_vars); |
|
|
4
|
|
|
|
|
1708
|
|
|
|
4
|
|
|
|
|
35
|
|
|
18
|
4
|
|
|
4
|
|
1687
|
use Fcntl qw(:seek); |
|
|
4
|
|
|
|
|
12
|
|
|
|
4
|
|
|
|
|
2207
|
|
|
19
|
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
Readonly::Scalar my $TEMPLATE_DELIMITER => q{@}; |
|
21
|
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
######################################################################## |
|
23
|
|
|
|
|
|
|
sub to_template_var { |
|
24
|
|
|
|
|
|
|
######################################################################## |
|
25
|
2
|
|
|
2
|
0
|
1347
|
my (@vars) = @_; |
|
26
|
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
my @template_vars |
|
28
|
2
|
|
|
|
|
4
|
= map { $TEMPLATE_DELIMITER . $_ . $TEMPLATE_DELIMITER } @vars; |
|
|
3
|
|
|
|
|
9
|
|
|
29
|
|
|
|
|
|
|
|
|
30
|
2
|
100
|
|
|
|
10
|
return wantarray ? @template_vars : $template_vars[0]; |
|
31
|
|
|
|
|
|
|
} ## end sub to_template_var |
|
32
|
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
######################################################################## |
|
34
|
|
|
|
|
|
|
sub fetch_template { |
|
35
|
|
|
|
|
|
|
######################################################################## |
|
36
|
0
|
|
|
0
|
0
|
|
my ( $fh, $template_start ) = @_; |
|
37
|
|
|
|
|
|
|
|
|
38
|
0
|
|
|
|
|
|
seek $fh, $template_start, SEEK_SET; |
|
39
|
|
|
|
|
|
|
|
|
40
|
0
|
|
|
|
|
|
my $template; |
|
41
|
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
{ |
|
43
|
0
|
|
|
|
|
|
local $RS = undef; |
|
|
0
|
|
|
|
|
|
|
|
44
|
0
|
|
|
|
|
|
$template = <$fh>; |
|
45
|
|
|
|
|
|
|
} |
|
46
|
|
|
|
|
|
|
|
|
47
|
0
|
|
|
|
|
|
return $template; |
|
48
|
|
|
|
|
|
|
} ## end sub fetch_template |
|
49
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
######################################################################## |
|
51
|
|
|
|
|
|
|
sub render_template { |
|
52
|
|
|
|
|
|
|
######################################################################## |
|
53
|
0
|
|
|
0
|
0
|
|
my ( $template, $parameters ) = @_; |
|
54
|
|
|
|
|
|
|
|
|
55
|
0
|
|
|
|
|
|
foreach my $p ( keys %{$parameters} ) { |
|
|
0
|
|
|
|
|
|
|
|
56
|
0
|
0
|
|
|
|
|
next if $p !~ /^$TEMPLATE_DELIMITER/xsm; |
|
57
|
|
|
|
|
|
|
|
|
58
|
0
|
|
0
|
|
|
|
my $val = $parameters->{$p} || $EMPTY; |
|
59
|
|
|
|
|
|
|
|
|
60
|
0
|
|
|
|
|
|
while ( $template =~ s/$p/$val/xsm ) { } |
|
61
|
|
|
|
|
|
|
} ## end foreach my $p ( keys %{$parameters...}) |
|
62
|
|
|
|
|
|
|
|
|
63
|
0
|
|
|
|
|
|
return $template; |
|
64
|
|
|
|
|
|
|
} |
|
65
|
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
######################################################################## |
|
67
|
|
|
|
|
|
|
sub html2pod { |
|
68
|
|
|
|
|
|
|
######################################################################## |
|
69
|
0
|
|
|
0
|
0
|
|
my ($html) = @_; |
|
70
|
|
|
|
|
|
|
|
|
71
|
0
|
|
0
|
|
|
|
my $pod = Pod::HTML2Pod::convert( |
|
72
|
|
|
|
|
|
|
a_href => $TRUE, |
|
73
|
|
|
|
|
|
|
a_name => $TRUE, |
|
74
|
|
|
|
|
|
|
content => $html // $EMPTY, |
|
75
|
|
|
|
|
|
|
); |
|
76
|
|
|
|
|
|
|
|
|
77
|
0
|
|
|
|
|
|
$pod =~ s/^=pod//xsm; |
|
78
|
0
|
|
|
|
|
|
$pod =~ s/^=cut//xsm; |
|
79
|
|
|
|
|
|
|
|
|
80
|
0
|
|
|
|
|
|
$pod =~ s/^\#.*$//gxsm; |
|
81
|
|
|
|
|
|
|
|
|
82
|
0
|
|
|
|
|
|
$pod = "\n$pod\n"; |
|
83
|
|
|
|
|
|
|
|
|
84
|
0
|
|
|
|
|
|
$pod =~ s/\A\n+/\n/xsm; |
|
85
|
0
|
|
|
|
|
|
$pod =~ s/\n+\z/\n/xsm; |
|
86
|
|
|
|
|
|
|
|
|
87
|
0
|
|
|
|
|
|
return $pod; |
|
88
|
|
|
|
|
|
|
} |
|
89
|
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
1; |