line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package HTML::TableContent::Template; |
2
|
|
|
|
|
|
|
|
3
|
3
|
|
|
3
|
|
180525
|
use strict; |
|
3
|
|
|
|
|
15
|
|
|
3
|
|
|
|
|
62
|
|
4
|
3
|
|
|
3
|
|
15
|
use warnings; |
|
3
|
|
|
|
|
6
|
|
|
3
|
|
|
|
|
57
|
|
5
|
3
|
|
|
3
|
|
12
|
use Carp qw/croak/; |
|
3
|
|
|
|
|
8
|
|
|
3
|
|
|
|
|
104
|
|
6
|
3
|
|
|
3
|
|
978
|
use MooX::ReturnModifiers; |
|
3
|
|
|
|
|
1070
|
|
|
3
|
|
|
|
|
101
|
|
7
|
2
|
|
|
3
|
|
941
|
use HTML::TableContent::Table; |
|
2
|
|
|
|
|
7
|
|
|
2
|
|
|
|
|
64
|
|
8
|
2
|
|
|
3
|
|
17
|
use HTML::TableContent::Table::Caption; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
43
|
|
9
|
2
|
|
|
2
|
|
10
|
use HTML::TableContent::Table::Header; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
219
|
|
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
our $VERSION = '1.00'; |
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
|
|
56775
|
my ( $self, @import ) = @_; |
22
|
|
|
|
|
|
|
|
23
|
45
|
|
|
|
|
126
|
my $target = caller; |
24
|
|
|
|
|
|
|
|
25
|
45
|
|
|
|
|
163
|
my %modifiers = return_modifiers($target); |
26
|
|
|
|
|
|
|
|
27
|
45
|
|
|
|
|
2063
|
my @target_isa; |
28
|
|
|
|
|
|
|
|
29
|
45
|
50
|
|
|
|
288
|
return if $target->can('_table'); |
30
|
|
|
|
|
|
|
|
31
|
2
|
|
|
2
|
|
17
|
{ no strict 'refs'; @target_isa = @{"${target}::ISA"} }; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
1059
|
|
|
45
|
|
|
|
|
79
|
|
|
45
|
|
|
|
|
79
|
|
|
45
|
|
|
|
|
195
|
|
32
|
|
|
|
|
|
|
|
33
|
45
|
50
|
|
|
|
132
|
if (@target_isa) { |
34
|
45
|
|
|
3
|
|
9495
|
eval '{ |
|
3
|
|
|
2
|
|
10
|
|
|
3
|
|
|
2
|
|
12
|
|
|
2
|
|
|
2
|
|
41
|
|
|
2
|
|
|
1
|
|
12
|
|
|
2
|
|
|
2
|
|
7
|
|
|
2
|
|
|
2
|
|
8
|
|
|
2
|
|
|
2
|
|
8
|
|
|
2
|
|
|
2
|
|
7
|
|
|
1
|
|
|
2
|
|
4
|
|
|
1
|
|
|
2
|
|
4
|
|
|
2
|
|
|
2
|
|
8
|
|
|
2
|
|
|
2
|
|
7
|
|
|
2
|
|
|
2
|
|
9
|
|
|
2
|
|
|
2
|
|
8
|
|
|
2
|
|
|
2
|
|
8
|
|
|
2
|
|
|
3
|
|
8
|
|
|
2
|
|
|
2
|
|
8
|
|
|
2
|
|
|
2
|
|
8
|
|
|
2
|
|
|
2
|
|
8
|
|
|
2
|
|
|
2
|
|
8
|
|
|
2
|
|
|
2
|
|
7
|
|
|
2
|
|
|
2
|
|
8
|
|
|
2
|
|
|
2
|
|
7
|
|
|
2
|
|
|
2
|
|
9
|
|
|
2
|
|
|
2
|
|
8
|
|
|
2
|
|
|
2
|
|
8
|
|
|
2
|
|
|
|
|
10
|
|
|
2
|
|
|
|
|
8
|
|
|
2
|
|
|
|
|
6
|
|
|
2
|
|
|
|
|
8
|
|
|
2
|
|
|
|
|
8
|
|
|
2
|
|
|
|
|
8
|
|
|
3
|
|
|
|
|
12
|
|
|
3
|
|
|
|
|
12
|
|
|
2
|
|
|
|
|
9
|
|
|
2
|
|
|
|
|
9
|
|
|
2
|
|
|
|
|
12
|
|
|
2
|
|
|
|
|
10
|
|
|
2
|
|
|
|
|
8
|
|
|
2
|
|
|
|
|
8
|
|
|
2
|
|
|
|
|
8
|
|
|
2
|
|
|
|
|
8
|
|
|
2
|
|
|
|
|
9
|
|
|
2
|
|
|
|
|
25
|
|
|
2
|
|
|
|
|
7
|
|
|
2
|
|
|
|
|
8
|
|
|
2
|
|
|
|
|
8
|
|
|
2
|
|
|
|
|
10
|
|
|
2
|
|
|
|
|
9
|
|
|
2
|
|
|
|
|
10
|
|
|
2
|
|
|
|
|
9
|
|
|
2
|
|
|
|
|
8
|
|
|
2
|
|
|
|
|
8
|
|
|
2
|
|
|
|
|
8
|
|
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
|
|
373
|
$modifiers{has}->( 'package' => ( is => 'ro', lazy => 1, default => sub { return $target; } ) ); |
|
0
|
|
|
|
|
0
|
|
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
my $apply_modifiers = sub { |
64
|
45
|
|
|
46
|
|
137
|
$modifiers{with}->('HTML::TableContent::Template::Base'); |
65
|
45
|
|
|
|
|
56193
|
}; |
66
|
|
|
|
|
|
|
|
67
|
45
|
|
|
|
|
215
|
for my $element (keys %TABLE) { |
68
|
180
|
|
|
|
|
326
|
my @element = (); |
69
|
|
|
|
|
|
|
my $option = sub { |
70
|
217
|
|
|
218
|
|
1541
|
my ( $name, %attributes ) = @_; |
71
|
|
|
|
|
|
|
|
72
|
217
|
|
|
|
|
533
|
my $element_data = { }; |
73
|
217
|
|
|
|
|
776
|
my %filtered_attributes = _filter_attributes($name, $element, %attributes); |
74
|
|
|
|
|
|
|
|
75
|
217
|
100
|
|
|
|
1189
|
if ( $element =~ m{caption|header}ixms ){ |
76
|
180
|
|
|
|
|
774
|
$modifiers{has}->( $name => %filtered_attributes ); |
77
|
|
|
|
|
|
|
} |
78
|
|
|
|
|
|
|
|
79
|
217
|
|
|
|
|
153344
|
delete $filtered_attributes{default}; |
80
|
|
|
|
|
|
|
|
81
|
217
|
|
|
|
|
526
|
$element_data->{$name} = \%filtered_attributes; |
82
|
|
|
|
|
|
|
|
83
|
217
|
|
|
|
|
911
|
my $spec = sprintf('_%s_spec', $element); |
84
|
217
|
100
|
|
|
|
1076
|
if ( $element =~ m{row|cell}ixms ) { |
85
|
|
|
|
|
|
|
$modifiers{around}->( |
86
|
|
|
|
|
|
|
$spec => sub { |
87
|
36
|
|
|
37
|
|
676
|
my ( $orig, $self ) = ( shift, shift ); |
88
|
36
|
|
|
|
|
706
|
return $self->$orig(@_), %$element_data; |
89
|
|
|
|
|
|
|
} |
90
|
37
|
|
|
|
|
184
|
); |
91
|
|
|
|
|
|
|
} else { |
92
|
180
|
|
|
|
|
396
|
push @element, $element_data; |
93
|
|
|
|
|
|
|
$modifiers{around}->( |
94
|
|
|
|
|
|
|
$spec => sub { |
95
|
180
|
|
|
181
|
|
2998
|
my ( $orig, $self ) = ( shift, shift ); |
96
|
180
|
|
|
|
|
3520
|
return $self->$orig(@_), \@element; |
97
|
|
|
|
|
|
|
} |
98
|
180
|
|
|
|
|
1011
|
); |
99
|
|
|
|
|
|
|
} |
100
|
217
|
|
|
|
|
59173
|
return; |
101
|
180
|
|
|
|
|
710
|
}; |
102
|
|
|
|
|
|
|
|
103
|
2
|
|
|
2
|
|
19
|
{ no strict 'refs'; *{"${target}::$element"} = $option; } |
|
2
|
|
|
|
|
12
|
|
|
2
|
|
|
|
|
732
|
|
|
180
|
|
|
|
|
313
|
|
|
180
|
|
|
|
|
237
|
|
|
180
|
|
|
|
|
793
|
|
104
|
|
|
|
|
|
|
} |
105
|
|
|
|
|
|
|
|
106
|
45
|
|
|
|
|
139
|
$apply_modifiers->(); |
107
|
|
|
|
|
|
|
|
108
|
45
|
|
|
|
|
54526
|
return; |
109
|
|
|
|
|
|
|
} |
110
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
sub _filter_attributes { |
112
|
218
|
|
|
218
|
|
629
|
my ($name, $element, %attributes) = @_; |
113
|
|
|
|
|
|
|
|
114
|
218
|
|
|
|
|
507
|
$attributes{template_attr} = $name; |
115
|
|
|
|
|
|
|
|
116
|
218
|
100
|
|
|
|
600
|
if ( ! exists $attributes{text} ) { |
117
|
161
|
|
|
|
|
316
|
$attributes{text} = $name; |
118
|
|
|
|
|
|
|
} |
119
|
|
|
|
|
|
|
|
120
|
218
|
100
|
100
|
|
|
575
|
if ( $element eq 'cell' && exists $attributes{alternate_classes} ) { |
121
|
4
|
|
|
|
|
11
|
my @classes = @{ $attributes{alternate_classes} }; |
|
4
|
|
|
|
|
15
|
|
122
|
4
|
|
|
|
|
12
|
$attributes{oac} = \@classes; |
123
|
|
|
|
|
|
|
} |
124
|
|
|
|
|
|
|
|
125
|
218
|
|
|
|
|
787
|
my %tattr = %attributes; |
126
|
218
|
|
|
|
|
489
|
$attributes{is} = 'ro'; |
127
|
218
|
|
|
|
|
350
|
$attributes{lazy} = 1; |
128
|
218
|
100
|
|
|
|
1108
|
if ( $element =~ m{row|cell}ixms ) { |
129
|
37
|
|
|
0
|
|
174
|
$attributes{default} = sub { return \%tattr; }; |
|
0
|
|
|
|
|
0
|
|
130
|
|
|
|
|
|
|
} else { |
131
|
180
|
|
|
|
|
375
|
my $class = $TABLE{$element}; |
132
|
180
|
|
|
180
|
|
856
|
$attributes{default} = sub { my %aah = %tattr; return $class->new(\%aah); }; |
|
180
|
|
|
|
|
2403
|
|
|
180
|
|
|
|
|
3314
|
|
133
|
|
|
|
|
|
|
} |
134
|
|
|
|
|
|
|
|
135
|
217
|
|
|
|
|
1306
|
return %attributes; |
136
|
|
|
|
|
|
|
} |
137
|
|
|
|
|
|
|
|
138
|
|
|
|
|
|
|
1; |
139
|
|
|
|
|
|
|
|
140
|
|
|
|
|
|
|
__END__ |