line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package HTML::TableContent::Template; |
2
|
|
|
|
|
|
|
|
3
|
3
|
|
|
3
|
|
57493
|
use strict; |
|
3
|
|
|
|
|
6
|
|
|
3
|
|
|
|
|
48
|
|
4
|
3
|
|
|
3
|
|
9
|
use warnings; |
|
3
|
|
|
|
|
4
|
|
|
3
|
|
|
|
|
41
|
|
5
|
3
|
|
|
3
|
|
7
|
use Carp qw/croak/; |
|
3
|
|
|
|
|
737
|
|
|
3
|
|
|
|
|
82
|
|
6
|
3
|
|
|
3
|
|
741
|
use MooX::ReturnModifiers; |
|
3
|
|
|
|
|
1001
|
|
|
3
|
|
|
|
|
90
|
|
7
|
2
|
|
|
3
|
|
692
|
use HTML::TableContent::Table; |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
45
|
|
8
|
2
|
|
|
3
|
|
14
|
use HTML::TableContent::Table::Caption; |
|
2
|
|
|
|
|
2
|
|
|
2
|
|
|
|
|
31
|
|
9
|
2
|
|
|
2
|
|
6
|
use HTML::TableContent::Table::Header; |
|
2
|
|
|
|
|
2
|
|
|
2
|
|
|
|
|
155
|
|
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
our $VERSION = '0.17'; |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
my %TABLE = ( |
14
|
|
|
|
|
|
|
caption => 'HTML::TableContent::Table::Caption', |
15
|
|
|
|
|
|
|
header => 'HTML::TableContent::Table::Header', |
16
|
|
|
|
|
|
|
row => 'HTML::TableContent::Table::Row', |
17
|
|
|
|
|
|
|
cell => 'HTML::TableContent::Table::Row::Cell', |
18
|
|
|
|
|
|
|
); |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
sub import { |
21
|
45
|
|
|
45
|
|
36503
|
my ( $self, @import ) = @_; |
22
|
|
|
|
|
|
|
|
23
|
45
|
|
|
|
|
74
|
my $target = caller; |
24
|
|
|
|
|
|
|
|
25
|
45
|
|
|
|
|
109
|
my %modifiers = return_modifiers($target); |
26
|
|
|
|
|
|
|
|
27
|
45
|
|
|
|
|
1240
|
my @target_isa; |
28
|
|
|
|
|
|
|
|
29
|
45
|
50
|
|
|
|
229
|
return if $target->can('_table'); |
30
|
|
|
|
|
|
|
|
31
|
2
|
|
|
2
|
|
7
|
{ no strict 'refs'; @target_isa = @{"${target}::ISA"} }; |
|
2
|
|
|
|
|
2
|
|
|
2
|
|
|
|
|
764
|
|
|
45
|
|
|
|
|
32
|
|
|
45
|
|
|
|
|
37
|
|
|
45
|
|
|
|
|
139
|
|
32
|
|
|
|
|
|
|
|
33
|
45
|
50
|
|
|
|
137
|
if (@target_isa) { |
34
|
45
|
|
|
2
|
|
6789
|
eval '{ |
|
2
|
|
|
2
|
|
4
|
|
|
2
|
|
|
2
|
|
5
|
|
|
2
|
|
|
2
|
|
4
|
|
|
2
|
|
|
2
|
|
6
|
|
|
2
|
|
|
2
|
|
3
|
|
|
2
|
|
|
2
|
|
6
|
|
|
2
|
|
|
2
|
|
4
|
|
|
2
|
|
|
1
|
|
6
|
|
|
2
|
|
|
2
|
|
4
|
|
|
2
|
|
|
2
|
|
6
|
|
|
2
|
|
|
2
|
|
5
|
|
|
2
|
|
|
2
|
|
7
|
|
|
2
|
|
|
2
|
|
4
|
|
|
2
|
|
|
3
|
|
14
|
|
|
2
|
|
|
3
|
|
4
|
|
|
2
|
|
|
2
|
|
5
|
|
|
1
|
|
|
2
|
|
2
|
|
|
1
|
|
|
2
|
|
2
|
|
|
2
|
|
|
2
|
|
4
|
|
|
2
|
|
|
2
|
|
5
|
|
|
2
|
|
|
2
|
|
3
|
|
|
2
|
|
|
2
|
|
7
|
|
|
2
|
|
|
2
|
|
4
|
|
|
2
|
|
|
2
|
|
6
|
|
|
2
|
|
|
2
|
|
4
|
|
|
2
|
|
|
2
|
|
6
|
|
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
5
|
|
|
3
|
|
|
|
|
6
|
|
|
3
|
|
|
|
|
8
|
|
|
3
|
|
|
|
|
6
|
|
|
3
|
|
|
|
|
6
|
|
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
8
|
|
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
6
|
|
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
7
|
|
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
6
|
|
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
6
|
|
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
6
|
|
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
7
|
|
|
2
|
|
|
|
|
8
|
|
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
6
|
|
35
|
|
|
|
|
|
|
package ' . $target . '; |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
sub _caption_spec { |
38
|
|
|
|
|
|
|
my ($class, @meta) = @_; |
39
|
|
|
|
|
|
|
return $class->maybe::next::method(@meta); |
40
|
|
|
|
|
|
|
} |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
sub _header_spec { |
43
|
|
|
|
|
|
|
my ($class, @meta) = @_; |
44
|
|
|
|
|
|
|
return $class->maybe::next::method(@meta); |
45
|
|
|
|
|
|
|
} |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
sub _row_spec { |
48
|
|
|
|
|
|
|
my ($class, @meta) = @_; |
49
|
|
|
|
|
|
|
return $class->maybe::next::method(@meta); |
50
|
|
|
|
|
|
|
} |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
sub _cell_spec { |
53
|
|
|
|
|
|
|
my ($class, @meta) = @_; |
54
|
|
|
|
|
|
|
return $class->maybe::next::method(@meta); |
55
|
|
|
|
|
|
|
} |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
1; |
58
|
|
|
|
|
|
|
}'; |
59
|
|
|
|
|
|
|
} |
60
|
|
|
|
|
|
|
|
61
|
45
|
|
|
1
|
|
213
|
$modifiers{has}->( 'package' => ( is => 'ro', lazy => 1, default => sub { return $target; } ) ); |
|
0
|
|
|
|
|
0
|
|
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
my $apply_modifiers = sub { |
64
|
45
|
|
|
46
|
|
99
|
$modifiers{with}->('HTML::TableContent::Template::Base'); |
65
|
45
|
|
|
|
|
34732
|
}; |
66
|
|
|
|
|
|
|
|
67
|
45
|
|
|
|
|
116
|
for my $element (keys %TABLE) { |
68
|
180
|
|
|
|
|
149
|
my @element = (); |
69
|
|
|
|
|
|
|
my $option = sub { |
70
|
217
|
|
|
218
|
|
937
|
my ( $name, %attributes ) = @_; |
71
|
|
|
|
|
|
|
|
72
|
217
|
|
|
|
|
263
|
my $element_data = { }; |
73
|
217
|
|
|
|
|
510
|
my %filtered_attributes = _filter_attributes($name, $element, %attributes); |
74
|
|
|
|
|
|
|
|
75
|
217
|
100
|
|
|
|
845
|
if ( $element =~ m{caption|header}ixms ){ |
76
|
180
|
|
|
|
|
545
|
$modifiers{has}->( $name => %filtered_attributes ); |
77
|
|
|
|
|
|
|
} |
78
|
|
|
|
|
|
|
|
79
|
217
|
|
|
|
|
92273
|
delete $filtered_attributes{default}; |
80
|
|
|
|
|
|
|
|
81
|
217
|
|
|
|
|
311
|
$element_data->{$name} = \%filtered_attributes; |
82
|
|
|
|
|
|
|
|
83
|
217
|
|
|
|
|
610
|
my $spec = sprintf('_%s_spec', $element); |
84
|
217
|
100
|
|
|
|
770
|
if ( $element =~ m{row|cell}ixms ) { |
85
|
|
|
|
|
|
|
$modifiers{around}->( |
86
|
|
|
|
|
|
|
$spec => sub { |
87
|
36
|
|
|
37
|
|
492
|
my ( $orig, $self ) = ( shift, shift ); |
88
|
36
|
|
|
|
|
601
|
return $self->$orig(@_), %$element_data; |
89
|
|
|
|
|
|
|
} |
90
|
37
|
|
|
|
|
133
|
); |
91
|
|
|
|
|
|
|
} else { |
92
|
180
|
|
|
|
|
235
|
push @element, $element_data; |
93
|
|
|
|
|
|
|
$modifiers{around}->( |
94
|
|
|
|
|
|
|
$spec => sub { |
95
|
180
|
|
|
181
|
|
2040
|
my ( $orig, $self ) = ( shift, shift ); |
96
|
180
|
|
|
|
|
2894
|
return $self->$orig(@_), \@element; |
97
|
|
|
|
|
|
|
} |
98
|
180
|
|
|
|
|
1090
|
); |
99
|
|
|
|
|
|
|
} |
100
|
217
|
|
|
|
|
38902
|
return; |
101
|
180
|
|
|
|
|
469
|
}; |
102
|
|
|
|
|
|
|
|
103
|
2
|
|
|
2
|
|
9
|
{ no strict 'refs'; *{"${target}::$element"} = $option; } |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
471
|
|
|
180
|
|
|
|
|
127
|
|
|
180
|
|
|
|
|
126
|
|
|
180
|
|
|
|
|
591
|
|
104
|
|
|
|
|
|
|
} |
105
|
|
|
|
|
|
|
|
106
|
45
|
|
|
|
|
64
|
$apply_modifiers->(); |
107
|
|
|
|
|
|
|
|
108
|
45
|
|
|
|
|
31436
|
return; |
109
|
|
|
|
|
|
|
} |
110
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
sub _filter_attributes { |
112
|
218
|
|
|
218
|
|
372
|
my ($name, $element, %attributes) = @_; |
113
|
|
|
|
|
|
|
|
114
|
218
|
|
|
|
|
297
|
$attributes{template_attr} = $name; |
115
|
|
|
|
|
|
|
|
116
|
218
|
100
|
|
|
|
416
|
if ( ! exists $attributes{text} ) { |
117
|
161
|
|
|
|
|
165
|
$attributes{text} = $name; |
118
|
|
|
|
|
|
|
} |
119
|
|
|
|
|
|
|
|
120
|
218
|
100
|
66
|
|
|
391
|
if ( $element eq 'cell' && exists $attributes{alternate_classes} ) { |
121
|
4
|
|
|
|
|
5
|
my @classes = @{ $attributes{alternate_classes} }; |
|
4
|
|
|
|
|
8
|
|
122
|
4
|
|
|
|
|
11
|
$attributes{oac} = \@classes; |
123
|
|
|
|
|
|
|
} |
124
|
|
|
|
|
|
|
|
125
|
218
|
|
|
|
|
504
|
my %tattr = %attributes; |
126
|
218
|
|
|
|
|
320
|
$attributes{is} = 'ro'; |
127
|
218
|
|
|
|
|
214
|
$attributes{lazy} = 1; |
128
|
218
|
100
|
|
|
|
761
|
if ( $element =~ m{row|cell}ixms ) { |
129
|
37
|
|
|
0
|
|
97
|
$attributes{default} = sub { return \%tattr; }; |
|
0
|
|
|
|
|
0
|
|
130
|
|
|
|
|
|
|
} else { |
131
|
180
|
|
|
|
|
188
|
my $class = $TABLE{$element}; |
132
|
180
|
|
|
180
|
|
546
|
$attributes{default} = sub { my %aah = %tattr; return $class->new(\%aah); }; |
|
180
|
|
|
|
|
1644
|
|
|
180
|
|
|
|
|
2531
|
|
133
|
|
|
|
|
|
|
} |
134
|
|
|
|
|
|
|
|
135
|
217
|
|
|
|
|
995
|
return %attributes; |
136
|
|
|
|
|
|
|
} |
137
|
|
|
|
|
|
|
|
138
|
|
|
|
|
|
|
1; |
139
|
|
|
|
|
|
|
|
140
|
|
|
|
|
|
|
__END__ |