| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package Tags::HTML::Element::A; |
|
2
|
|
|
|
|
|
|
|
|
3
|
7
|
|
|
7
|
|
343963
|
use base qw(Tags::HTML); |
|
|
7
|
|
|
|
|
16
|
|
|
|
7
|
|
|
|
|
4134
|
|
|
4
|
7
|
|
|
7
|
|
63351
|
use strict; |
|
|
7
|
|
|
|
|
18
|
|
|
|
7
|
|
|
|
|
183
|
|
|
5
|
7
|
|
|
7
|
|
35
|
use warnings; |
|
|
7
|
|
|
|
|
2157
|
|
|
|
7
|
|
|
|
|
486
|
|
|
6
|
|
|
|
|
|
|
|
|
7
|
7
|
|
|
7
|
|
43
|
use Error::Pure qw(err); |
|
|
7
|
|
|
|
|
23
|
|
|
|
7
|
|
|
|
|
442
|
|
|
8
|
7
|
|
|
7
|
|
57
|
use Scalar::Util qw(blessed); |
|
|
7
|
|
|
|
|
14
|
|
|
|
7
|
|
|
|
|
459
|
|
|
9
|
7
|
|
|
7
|
|
4126
|
use Tags::HTML::Element::Utils qw(tags_data tags_value); |
|
|
7
|
|
|
|
|
41
|
|
|
|
7
|
|
|
|
|
209
|
|
|
10
|
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
our $VERSION = 0.15; |
|
12
|
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
sub _cleanup { |
|
14
|
1
|
|
|
1
|
|
235149
|
my $self = shift; |
|
15
|
|
|
|
|
|
|
|
|
16
|
1
|
|
|
|
|
2
|
delete $self->{'_a'}; |
|
17
|
|
|
|
|
|
|
|
|
18
|
1
|
|
|
|
|
2
|
return; |
|
19
|
|
|
|
|
|
|
} |
|
20
|
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
sub _init { |
|
22
|
9
|
|
|
9
|
|
1144955
|
my ($self, $a) = @_; |
|
23
|
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
# Check a. |
|
25
|
9
|
100
|
100
|
|
|
114
|
if (! defined $a |
|
|
|
|
100
|
|
|
|
|
|
26
|
|
|
|
|
|
|
|| ! blessed($a) |
|
27
|
|
|
|
|
|
|
|| ! $a->isa('Data::HTML::Element::A')) { |
|
28
|
|
|
|
|
|
|
|
|
29
|
3
|
|
|
|
|
63
|
err "Anchor object must be a 'Data::HTML::Element::A' instance."; |
|
30
|
|
|
|
|
|
|
} |
|
31
|
|
|
|
|
|
|
|
|
32
|
6
|
|
|
|
|
19
|
$self->{'_a'} = $a; |
|
33
|
|
|
|
|
|
|
|
|
34
|
6
|
|
|
|
|
15
|
return; |
|
35
|
|
|
|
|
|
|
} |
|
36
|
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
# Process 'Tags'. |
|
38
|
|
|
|
|
|
|
sub _process { |
|
39
|
5
|
|
|
5
|
|
2483
|
my $self = shift; |
|
40
|
|
|
|
|
|
|
|
|
41
|
5
|
100
|
|
|
|
15
|
if (! exists $self->{'_a'}) { |
|
42
|
1
|
|
|
|
|
3
|
return; |
|
43
|
|
|
|
|
|
|
} |
|
44
|
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
$self->{'tags'}->put( |
|
46
|
|
|
|
|
|
|
['b', 'a'], |
|
47
|
|
|
|
|
|
|
tags_value($self, $self->{'_a'}, 'css_class', 'class'), |
|
48
|
|
|
|
|
|
|
tags_value($self, $self->{'_a'}, 'id'), |
|
49
|
|
|
|
|
|
|
tags_value($self, $self->{'_a'}, 'target'), |
|
50
|
4
|
|
|
|
|
23
|
tags_value($self, $self->{'_a'}, 'url', 'href'), |
|
51
|
|
|
|
|
|
|
); |
|
52
|
4
|
|
|
|
|
405
|
tags_data($self, $self->{'_a'}); |
|
53
|
4
|
|
|
|
|
18
|
$self->{'tags'}->put( |
|
54
|
|
|
|
|
|
|
['e', 'a'], |
|
55
|
|
|
|
|
|
|
); |
|
56
|
|
|
|
|
|
|
|
|
57
|
4
|
|
|
|
|
189
|
return; |
|
58
|
|
|
|
|
|
|
} |
|
59
|
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
sub _process_css { |
|
61
|
2
|
|
|
2
|
|
1562
|
my $self = shift; |
|
62
|
|
|
|
|
|
|
|
|
63
|
2
|
|
|
|
|
5
|
return; |
|
64
|
|
|
|
|
|
|
} |
|
65
|
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
1; |
|
67
|
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
__END__ |
|
69
|
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
=pod |
|
71
|
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
=encoding utf8 |
|
73
|
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
=head1 NAME |
|
75
|
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
Tags::HTML::Element::A - Tags helper for HTML a element. |
|
77
|
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
=head1 SYNOPSIS |
|
79
|
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
use Tags::HTML::Element::A; |
|
81
|
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
my $obj = Tags::HTML::Element::A->new(%params); |
|
83
|
|
|
|
|
|
|
$obj->cleanup; |
|
84
|
|
|
|
|
|
|
$obj->init($a); |
|
85
|
|
|
|
|
|
|
$obj->prepare; |
|
86
|
|
|
|
|
|
|
$obj->process; |
|
87
|
|
|
|
|
|
|
$obj->process_css; |
|
88
|
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
=head1 METHODS |
|
90
|
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
=head2 C<new> |
|
92
|
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
my $obj = Tags::HTML::Element::A->new(%params); |
|
94
|
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
Constructor. |
|
96
|
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
=over 8 |
|
98
|
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
=item * C<css> |
|
100
|
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
L<CSS::Struct::Output> object for L<process_css> processing. |
|
102
|
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
Default value is undef. |
|
104
|
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
=item * C<tags> |
|
106
|
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
L<Tags::Output> object. |
|
108
|
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
Default value is undef. |
|
110
|
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
=back |
|
112
|
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
=head2 C<cleanup> |
|
114
|
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
$obj->cleanup; |
|
116
|
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
Process cleanup after page run. |
|
118
|
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
In this case cleanup internal representation of a set by L<init>. |
|
120
|
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
Returns undef. |
|
122
|
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
=head2 C<init> |
|
124
|
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
$obj->init($a); |
|
126
|
|
|
|
|
|
|
|
|
127
|
|
|
|
|
|
|
Process initialization in page run. |
|
128
|
|
|
|
|
|
|
|
|
129
|
|
|
|
|
|
|
Accepted C<$a> is L<Data::HTML::Element::A>. |
|
130
|
|
|
|
|
|
|
|
|
131
|
|
|
|
|
|
|
Returns undef. |
|
132
|
|
|
|
|
|
|
|
|
133
|
|
|
|
|
|
|
=head2 C<prepare> |
|
134
|
|
|
|
|
|
|
|
|
135
|
|
|
|
|
|
|
$obj->prepare; |
|
136
|
|
|
|
|
|
|
|
|
137
|
|
|
|
|
|
|
Process initialization before page run. |
|
138
|
|
|
|
|
|
|
|
|
139
|
|
|
|
|
|
|
Do nothing in this object. |
|
140
|
|
|
|
|
|
|
|
|
141
|
|
|
|
|
|
|
Returns undef. |
|
142
|
|
|
|
|
|
|
|
|
143
|
|
|
|
|
|
|
=head2 C<process> |
|
144
|
|
|
|
|
|
|
|
|
145
|
|
|
|
|
|
|
$obj->process; |
|
146
|
|
|
|
|
|
|
|
|
147
|
|
|
|
|
|
|
Process L<Tags> structure for HTML a element to output. |
|
148
|
|
|
|
|
|
|
|
|
149
|
|
|
|
|
|
|
Do nothing in case without inicialization by L<init>. |
|
150
|
|
|
|
|
|
|
|
|
151
|
|
|
|
|
|
|
Returns undef. |
|
152
|
|
|
|
|
|
|
|
|
153
|
|
|
|
|
|
|
=head2 C<process_css> |
|
154
|
|
|
|
|
|
|
|
|
155
|
|
|
|
|
|
|
$obj->process_css; |
|
156
|
|
|
|
|
|
|
|
|
157
|
|
|
|
|
|
|
Process L<CSS::Struct> structure for HTML a element to output. |
|
158
|
|
|
|
|
|
|
|
|
159
|
|
|
|
|
|
|
Do nothing in case without inicialization by L<init>. |
|
160
|
|
|
|
|
|
|
|
|
161
|
|
|
|
|
|
|
Returns undef. |
|
162
|
|
|
|
|
|
|
|
|
163
|
|
|
|
|
|
|
=head1 ERRORS |
|
164
|
|
|
|
|
|
|
|
|
165
|
|
|
|
|
|
|
new(): |
|
166
|
|
|
|
|
|
|
From Tags::HTML::new(): |
|
167
|
|
|
|
|
|
|
Parameter 'css' must be a 'CSS::Struct::Output::*' class. |
|
168
|
|
|
|
|
|
|
Parameter 'tags' must be a 'Tags::Output::*' class. |
|
169
|
|
|
|
|
|
|
|
|
170
|
|
|
|
|
|
|
init(): |
|
171
|
|
|
|
|
|
|
Anchor object must be a 'Data::HTML::Element::A' instance. |
|
172
|
|
|
|
|
|
|
|
|
173
|
|
|
|
|
|
|
process(): |
|
174
|
|
|
|
|
|
|
From Tags::HTML::process(): |
|
175
|
|
|
|
|
|
|
Parameter 'tags' isn't defined. |
|
176
|
|
|
|
|
|
|
|
|
177
|
|
|
|
|
|
|
process_css(): |
|
178
|
|
|
|
|
|
|
From Tags::HTML::process_css(): |
|
179
|
|
|
|
|
|
|
Parameter 'css' isn't defined. |
|
180
|
|
|
|
|
|
|
|
|
181
|
|
|
|
|
|
|
=head1 EXAMPLE |
|
182
|
|
|
|
|
|
|
|
|
183
|
|
|
|
|
|
|
=for comment filename=create_and_print_a.pl |
|
184
|
|
|
|
|
|
|
|
|
185
|
|
|
|
|
|
|
use strict; |
|
186
|
|
|
|
|
|
|
use warnings; |
|
187
|
|
|
|
|
|
|
|
|
188
|
|
|
|
|
|
|
use CSS::Struct::Output::Indent; |
|
189
|
|
|
|
|
|
|
use Data::HTML::Element::A; |
|
190
|
|
|
|
|
|
|
use Tags::HTML::Element::A; |
|
191
|
|
|
|
|
|
|
use Tags::Output::Indent; |
|
192
|
|
|
|
|
|
|
|
|
193
|
|
|
|
|
|
|
# Object. |
|
194
|
|
|
|
|
|
|
my $css = CSS::Struct::Output::Indent->new; |
|
195
|
|
|
|
|
|
|
my $tags = Tags::Output::Indent->new( |
|
196
|
|
|
|
|
|
|
'xml' => 1, |
|
197
|
|
|
|
|
|
|
); |
|
198
|
|
|
|
|
|
|
my $obj = Tags::HTML::Element::A->new( |
|
199
|
|
|
|
|
|
|
'css' => $css, |
|
200
|
|
|
|
|
|
|
'tags' => $tags, |
|
201
|
|
|
|
|
|
|
); |
|
202
|
|
|
|
|
|
|
|
|
203
|
|
|
|
|
|
|
# Data object for a. |
|
204
|
|
|
|
|
|
|
my $a = Data::HTML::Element::A->new( |
|
205
|
|
|
|
|
|
|
'css_class' => 'a', |
|
206
|
|
|
|
|
|
|
'data' => ['Link'], |
|
207
|
|
|
|
|
|
|
'url' => 'http://example.com', |
|
208
|
|
|
|
|
|
|
); |
|
209
|
|
|
|
|
|
|
|
|
210
|
|
|
|
|
|
|
# Initialize. |
|
211
|
|
|
|
|
|
|
$obj->init($a); |
|
212
|
|
|
|
|
|
|
|
|
213
|
|
|
|
|
|
|
# Process a. |
|
214
|
|
|
|
|
|
|
$obj->process; |
|
215
|
|
|
|
|
|
|
$obj->process_css; |
|
216
|
|
|
|
|
|
|
|
|
217
|
|
|
|
|
|
|
# Print out. |
|
218
|
|
|
|
|
|
|
print "HTML:\n"; |
|
219
|
|
|
|
|
|
|
print $tags->flush; |
|
220
|
|
|
|
|
|
|
print "\n\n"; |
|
221
|
|
|
|
|
|
|
print "CSS:\n"; |
|
222
|
|
|
|
|
|
|
print $css->flush; |
|
223
|
|
|
|
|
|
|
|
|
224
|
|
|
|
|
|
|
# Output: |
|
225
|
|
|
|
|
|
|
# HTML: |
|
226
|
|
|
|
|
|
|
# <a class="a" href="http://example.com"> |
|
227
|
|
|
|
|
|
|
# Link |
|
228
|
|
|
|
|
|
|
# </a> |
|
229
|
|
|
|
|
|
|
# |
|
230
|
|
|
|
|
|
|
# CSS: |
|
231
|
|
|
|
|
|
|
# - no CSS now. |
|
232
|
|
|
|
|
|
|
|
|
233
|
|
|
|
|
|
|
=head1 DEPENDENCIES |
|
234
|
|
|
|
|
|
|
|
|
235
|
|
|
|
|
|
|
L<Class::Utils>, |
|
236
|
|
|
|
|
|
|
L<Error::Pure>, |
|
237
|
|
|
|
|
|
|
L<Scalar::Util>, |
|
238
|
|
|
|
|
|
|
L<Tags::HTML>. |
|
239
|
|
|
|
|
|
|
|
|
240
|
|
|
|
|
|
|
=head1 REPOSITORY |
|
241
|
|
|
|
|
|
|
|
|
242
|
|
|
|
|
|
|
L<https://github.com/michal-josef-spacek/Tags-HTML-Element> |
|
243
|
|
|
|
|
|
|
|
|
244
|
|
|
|
|
|
|
=head1 AUTHOR |
|
245
|
|
|
|
|
|
|
|
|
246
|
|
|
|
|
|
|
Michal Josef Špaček L<mailto:skim@cpan.org> |
|
247
|
|
|
|
|
|
|
|
|
248
|
|
|
|
|
|
|
L<http://skim.cz> |
|
249
|
|
|
|
|
|
|
|
|
250
|
|
|
|
|
|
|
=head1 LICENSE AND COPYRIGHT |
|
251
|
|
|
|
|
|
|
|
|
252
|
|
|
|
|
|
|
© 2022-2024 Michal Josef Špaček |
|
253
|
|
|
|
|
|
|
|
|
254
|
|
|
|
|
|
|
BSD 2-Clause License |
|
255
|
|
|
|
|
|
|
|
|
256
|
|
|
|
|
|
|
=head1 VERSION |
|
257
|
|
|
|
|
|
|
|
|
258
|
|
|
|
|
|
|
0.15 |
|
259
|
|
|
|
|
|
|
|
|
260
|
|
|
|
|
|
|
=cut |