line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package HTML::Auto; |
2
|
|
|
|
|
|
|
# ABSTRACT: write HTML for common elements |
3
|
|
|
|
|
|
|
$HTML::Auto::VERSION = '0.09'; |
4
|
2
|
|
|
2
|
|
26615
|
use warnings; |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
65
|
|
5
|
2
|
|
|
2
|
|
6
|
use strict; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
33
|
|
6
|
|
|
|
|
|
|
|
7
|
2
|
|
|
2
|
|
915
|
use Template; |
|
2
|
|
|
|
|
32309
|
|
|
2
|
|
|
|
|
49
|
|
8
|
2
|
|
|
2
|
|
761
|
use HTML::Auto::Templates; |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
677
|
|
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
require Exporter; |
11
|
|
|
|
|
|
|
our @ISA = qw(Exporter); |
12
|
|
|
|
|
|
|
our @EXPORT_OK = qw(matrix h v); |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
sub matrix { |
15
|
3
|
|
|
3
|
1
|
1700
|
my ($cols,$lines,$data,$options) = @_; |
16
|
|
|
|
|
|
|
|
17
|
3
|
50
|
|
|
|
13
|
if ($options->{ucfirst}) { |
18
|
0
|
|
|
|
|
0
|
foreach (@$cols, @$lines) { |
19
|
0
|
|
|
|
|
0
|
$_ = ucfirst($_); |
20
|
|
|
|
|
|
|
} |
21
|
|
|
|
|
|
|
} |
22
|
|
|
|
|
|
|
|
23
|
3
|
|
|
|
|
5
|
my $vals = []; |
24
|
3
|
|
|
|
|
6
|
my $attrs = []; |
25
|
3
|
|
|
|
|
6
|
my $more = []; |
26
|
|
|
|
|
|
|
|
27
|
3
|
|
|
|
|
8
|
foreach my $row (@$data) { |
28
|
6
|
|
|
|
|
7
|
my $vrow = []; |
29
|
6
|
|
|
|
|
5
|
my $arow = []; |
30
|
6
|
|
|
|
|
7
|
my $mrow = []; |
31
|
6
|
|
|
|
|
12
|
foreach(@$row){ |
32
|
12
|
100
|
|
|
|
17
|
if (ref($_)){ |
33
|
1
|
|
|
|
|
4
|
push @$vrow, $_->{v}; |
34
|
1
|
|
|
|
|
3
|
push @$arow, $_->{a}; |
35
|
1
|
|
|
|
|
3
|
push @$mrow, $_->{more_info}; |
36
|
|
|
|
|
|
|
} |
37
|
|
|
|
|
|
|
else { |
38
|
11
|
|
|
|
|
14
|
push @$vrow, $_; |
39
|
11
|
|
|
|
|
8
|
push @$arow, undef; |
40
|
11
|
|
|
|
|
15
|
push @$mrow, undef; |
41
|
|
|
|
|
|
|
} |
42
|
|
|
|
|
|
|
} |
43
|
6
|
|
|
|
|
9
|
push @$vals, $vrow; |
44
|
6
|
|
|
|
|
6
|
push @$attrs, $arow; |
45
|
6
|
|
|
|
|
13
|
push @$more, $mrow; |
46
|
|
|
|
|
|
|
} |
47
|
|
|
|
|
|
|
|
48
|
3
|
|
|
|
|
18
|
my $vars = { |
49
|
|
|
|
|
|
|
cols => $cols, |
50
|
|
|
|
|
|
|
lines => $lines, |
51
|
|
|
|
|
|
|
vals => $vals, |
52
|
|
|
|
|
|
|
attrs => $attrs, |
53
|
|
|
|
|
|
|
more => $more, |
54
|
|
|
|
|
|
|
}; |
55
|
|
|
|
|
|
|
$vars->{css} = $options->{css} |
56
|
3
|
50
|
|
|
|
12
|
if $options->{css}; |
57
|
|
|
|
|
|
|
$vars->{myformat} = $options->{format} |
58
|
3
|
50
|
|
|
|
7
|
if $options->{format}; |
59
|
|
|
|
|
|
|
$vars->{diagonal} = $options->{diagonal} |
60
|
3
|
100
|
|
|
|
13
|
if $options->{diagonal}; |
61
|
|
|
|
|
|
|
|
62
|
3
|
|
|
|
|
5
|
my $template_name = 'matrix'; |
63
|
3
|
|
|
|
|
8
|
__process($template_name, $vars); |
64
|
|
|
|
|
|
|
} |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
sub h { |
67
|
1
|
|
|
1
|
1
|
75490
|
my (@list) = @_; |
68
|
|
|
|
|
|
|
|
69
|
1
|
|
|
|
|
3
|
my $vars = { |
70
|
|
|
|
|
|
|
list => [@list], |
71
|
|
|
|
|
|
|
}; |
72
|
1
|
|
|
|
|
2
|
my $template_name = 'h'; |
73
|
|
|
|
|
|
|
|
74
|
1
|
|
|
|
|
4
|
__process($template_name, $vars); |
75
|
|
|
|
|
|
|
} |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
sub v { |
78
|
1
|
|
|
1
|
1
|
858
|
my (@list) = @_; |
79
|
|
|
|
|
|
|
|
80
|
1
|
|
|
|
|
3
|
my $vars = { |
81
|
|
|
|
|
|
|
list => [@list], |
82
|
|
|
|
|
|
|
}; |
83
|
1
|
|
|
|
|
2
|
my $template_name = 'v'; |
84
|
|
|
|
|
|
|
|
85
|
1
|
|
|
|
|
4
|
__process($template_name, $vars); |
86
|
|
|
|
|
|
|
} |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
sub __process { |
89
|
5
|
|
|
5
|
|
10
|
my ($template_name,$vars) = @_; |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
# build html from template |
92
|
5
|
|
|
|
|
12
|
my $template_config = { |
93
|
|
|
|
|
|
|
INCLUDE_PATH => [ 'templates' ], |
94
|
|
|
|
|
|
|
}; |
95
|
5
|
|
|
|
|
48
|
my $template = Template->new({ |
96
|
|
|
|
|
|
|
LOAD_TEMPLATES => [ HTML::Auto::Templates->new($template_config) ], |
97
|
|
|
|
|
|
|
}); |
98
|
5
|
|
|
|
|
18731
|
my $html; |
99
|
5
|
|
|
|
|
22
|
$template->process($template_name, $vars, \$html); |
100
|
|
|
|
|
|
|
|
101
|
5
|
|
|
|
|
6301
|
return $html; |
102
|
|
|
|
|
|
|
} |
103
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
1; |
105
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
__END__ |