| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
|
|
2
|
|
|
|
|
|
|
use base qw(Tags::HTML); |
|
3
|
10
|
|
|
10
|
|
130483
|
use strict; |
|
|
10
|
|
|
|
|
51
|
|
|
|
10
|
|
|
|
|
2610
|
|
|
4
|
10
|
|
|
10
|
|
93731
|
use warnings; |
|
|
10
|
|
|
|
|
19
|
|
|
|
10
|
|
|
|
|
171
|
|
|
5
|
10
|
|
|
10
|
|
41
|
|
|
|
10
|
|
|
|
|
21
|
|
|
|
10
|
|
|
|
|
247
|
|
|
6
|
|
|
|
|
|
|
use Class::Utils qw(set_params split_params); |
|
7
|
10
|
|
|
10
|
|
49
|
use Error::Pure qw(err); |
|
|
10
|
|
|
|
|
15
|
|
|
|
10
|
|
|
|
|
421
|
|
|
8
|
10
|
|
|
10
|
|
51
|
use Scalar::Util qw(blessed); |
|
|
10
|
|
|
|
|
23
|
|
|
|
10
|
|
|
|
|
347
|
|
|
9
|
10
|
|
|
10
|
|
51
|
|
|
|
10
|
|
|
|
|
25
|
|
|
|
10
|
|
|
|
|
4737
|
|
|
10
|
|
|
|
|
|
|
our $VERSION = 0.07; |
|
11
|
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
# Process 'Tags'. |
|
13
|
|
|
|
|
|
|
my ($self, $input) = @_; |
|
14
|
|
|
|
|
|
|
|
|
15
|
5
|
|
|
5
|
|
6401
|
# Check input. |
|
16
|
|
|
|
|
|
|
if (! defined $input |
|
17
|
|
|
|
|
|
|
|| ! blessed($input) |
|
18
|
5
|
100
|
66
|
|
|
50
|
|| ! $input->isa('Data::HTML::Form::Input')) { |
|
|
|
|
66
|
|
|
|
|
|
19
|
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
err "Input object must be a 'Data::HTML::Form::Input' instance."; |
|
21
|
|
|
|
|
|
|
} |
|
22
|
1
|
|
|
|
|
4
|
|
|
23
|
|
|
|
|
|
|
$self->{'tags'}->put( |
|
24
|
|
|
|
|
|
|
['b', 'input'], |
|
25
|
4
|
50
|
|
|
|
19
|
$input->autofocus ? ( |
|
|
|
50
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
['a', 'autofocus', 'autofocus'], |
|
27
|
|
|
|
|
|
|
) : (), |
|
28
|
|
|
|
|
|
|
defined $input->css_class ? ( |
|
29
|
|
|
|
|
|
|
['a', 'class', $input->css_class], |
|
30
|
|
|
|
|
|
|
) : (), |
|
31
|
|
|
|
|
|
|
['a', 'type', $input->type], |
|
32
|
|
|
|
|
|
|
defined $input->id ? ( |
|
33
|
|
|
|
|
|
|
['a', 'name', $input->id], |
|
34
|
|
|
|
|
|
|
['a', 'id', $input->id], |
|
35
|
|
|
|
|
|
|
) : (), |
|
36
|
|
|
|
|
|
|
defined $input->value ? ( |
|
37
|
|
|
|
|
|
|
['a', 'value', $input->value], |
|
38
|
|
|
|
|
|
|
) : (), |
|
39
|
|
|
|
|
|
|
$input->checked ? ( |
|
40
|
|
|
|
|
|
|
['a', 'checked', 'checked'], |
|
41
|
|
|
|
|
|
|
) : (), |
|
42
|
|
|
|
|
|
|
defined $input->placeholder ? ( |
|
43
|
|
|
|
|
|
|
['a', 'placeholder', $input->placeholder], |
|
44
|
|
|
|
|
|
|
) : (), |
|
45
|
|
|
|
|
|
|
defined $input->size ? ( |
|
46
|
|
|
|
|
|
|
['a', 'size', $input->size], |
|
47
|
|
|
|
|
|
|
) : (), |
|
48
|
|
|
|
|
|
|
defined $input->readonly ? ( |
|
49
|
|
|
|
|
|
|
['a', 'readonly', 'readonly'], |
|
50
|
|
|
|
|
|
|
) : (), |
|
51
|
|
|
|
|
|
|
defined $input->disabled ? ( |
|
52
|
|
|
|
|
|
|
['a', 'disabled', 'disabled'], |
|
53
|
|
|
|
|
|
|
) : (), |
|
54
|
|
|
|
|
|
|
defined $input->min ? ( |
|
55
|
|
|
|
|
|
|
['a', 'min', $input->min], |
|
56
|
|
|
|
|
|
|
) : (), |
|
57
|
|
|
|
|
|
|
defined $input->max ? ( |
|
58
|
|
|
|
|
|
|
['a', 'max', $input->max], |
|
59
|
|
|
|
|
|
|
) : (), |
|
60
|
|
|
|
|
|
|
['e', 'input'], |
|
61
|
|
|
|
|
|
|
); |
|
62
|
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
return; |
|
64
|
|
|
|
|
|
|
} |
|
65
|
4
|
|
|
|
|
686
|
|
|
66
|
|
|
|
|
|
|
my ($self, $input) = @_; |
|
67
|
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
# Check input. |
|
69
|
2
|
|
|
2
|
|
4963
|
if (! defined $input |
|
70
|
|
|
|
|
|
|
|| ! blessed($input) |
|
71
|
|
|
|
|
|
|
|| ! $input->isa('Data::HTML::Form::Input')) { |
|
72
|
2
|
50
|
33
|
|
|
23
|
|
|
|
|
|
33
|
|
|
|
|
|
73
|
|
|
|
|
|
|
err "Input object must be a 'Data::HTML::Form::Input' instance."; |
|
74
|
|
|
|
|
|
|
} |
|
75
|
|
|
|
|
|
|
|
|
76
|
0
|
|
|
|
|
0
|
my $css_class = ''; |
|
77
|
|
|
|
|
|
|
if (defined $input->css_class) { |
|
78
|
|
|
|
|
|
|
$css_class = '.'.$input->css_class; |
|
79
|
2
|
|
|
|
|
6
|
} |
|
80
|
2
|
100
|
|
|
|
5
|
|
|
81
|
1
|
|
|
|
|
8
|
$self->{'css'}->put( |
|
82
|
|
|
|
|
|
|
['s', 'input'.$css_class.'[type=submit]:hover'], |
|
83
|
|
|
|
|
|
|
['d', 'background-color', '#45a049'], |
|
84
|
2
|
|
|
|
|
51
|
['e'], |
|
85
|
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
['s', 'input'.$css_class.'[type=submit]'], |
|
87
|
|
|
|
|
|
|
['d', 'width', '100%'], |
|
88
|
|
|
|
|
|
|
['d', 'background-color', '#4CAF50'], |
|
89
|
|
|
|
|
|
|
['d', 'color', 'white'], |
|
90
|
|
|
|
|
|
|
['d', 'padding', '14px 20px'], |
|
91
|
|
|
|
|
|
|
['d', 'margin', '8px 0'], |
|
92
|
|
|
|
|
|
|
['d', 'border', 'none'], |
|
93
|
|
|
|
|
|
|
['d', 'border-radius', '4px'], |
|
94
|
|
|
|
|
|
|
['d', 'cursor', 'pointer'], |
|
95
|
|
|
|
|
|
|
['e'], |
|
96
|
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
['s', 'input'.$css_class.'[type=submit][disabled=disabled]'], |
|
98
|
|
|
|
|
|
|
['d', 'background-color', '#888888'], |
|
99
|
|
|
|
|
|
|
['e'], |
|
100
|
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
['s', 'input'.$css_class.'[type=text]'], |
|
102
|
|
|
|
|
|
|
['s', 'input'.$css_class.'[type=date]'], |
|
103
|
|
|
|
|
|
|
['s', 'input'.$css_class.'[type=number]'], |
|
104
|
|
|
|
|
|
|
['d', 'width', '100%'], |
|
105
|
|
|
|
|
|
|
['d', 'padding', '12px 20px'], |
|
106
|
|
|
|
|
|
|
['d', 'margin', '8px 0'], |
|
107
|
|
|
|
|
|
|
['d', 'display', 'inline-block'], |
|
108
|
|
|
|
|
|
|
['d', 'border', '1px solid #ccc'], |
|
109
|
|
|
|
|
|
|
['d', 'border-radius', '4px'], |
|
110
|
|
|
|
|
|
|
['d', 'box-sizing', 'border-box'], |
|
111
|
|
|
|
|
|
|
['e'], |
|
112
|
|
|
|
|
|
|
); |
|
113
|
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
return; |
|
115
|
|
|
|
|
|
|
} |
|
116
|
|
|
|
|
|
|
|
|
117
|
2
|
|
|
|
|
1121
|
1; |
|
118
|
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
=pod |
|
121
|
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
=encoding utf8 |
|
123
|
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
=head1 NAME |
|
125
|
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
Tags::HTML::Form::Input - Tags helper for form input element. |
|
127
|
|
|
|
|
|
|
|
|
128
|
|
|
|
|
|
|
=head1 SYNOPSIS |
|
129
|
|
|
|
|
|
|
|
|
130
|
|
|
|
|
|
|
use Tags::HTML::Form::Input; |
|
131
|
|
|
|
|
|
|
|
|
132
|
|
|
|
|
|
|
my $obj = Tags::HTML::Form::Input->new(%params); |
|
133
|
|
|
|
|
|
|
$obj->process($input); |
|
134
|
|
|
|
|
|
|
$obj->process_css($input); |
|
135
|
|
|
|
|
|
|
|
|
136
|
|
|
|
|
|
|
=head1 METHODS |
|
137
|
|
|
|
|
|
|
|
|
138
|
|
|
|
|
|
|
=head2 C<new> |
|
139
|
|
|
|
|
|
|
|
|
140
|
|
|
|
|
|
|
my $obj = Tags::HTML::Form::Input->new(%params); |
|
141
|
|
|
|
|
|
|
|
|
142
|
|
|
|
|
|
|
Constructor. |
|
143
|
|
|
|
|
|
|
|
|
144
|
|
|
|
|
|
|
=over 8 |
|
145
|
|
|
|
|
|
|
|
|
146
|
|
|
|
|
|
|
=item * C<css> |
|
147
|
|
|
|
|
|
|
|
|
148
|
|
|
|
|
|
|
'CSS::Struct::Output' object for L<process_css> processing. |
|
149
|
|
|
|
|
|
|
|
|
150
|
|
|
|
|
|
|
Default value is undef. |
|
151
|
|
|
|
|
|
|
|
|
152
|
|
|
|
|
|
|
=item * C<tags> |
|
153
|
|
|
|
|
|
|
|
|
154
|
|
|
|
|
|
|
'Tags::Output' object. |
|
155
|
|
|
|
|
|
|
|
|
156
|
|
|
|
|
|
|
Default value is undef. |
|
157
|
|
|
|
|
|
|
|
|
158
|
|
|
|
|
|
|
=back |
|
159
|
|
|
|
|
|
|
|
|
160
|
|
|
|
|
|
|
=head2 C<process> |
|
161
|
|
|
|
|
|
|
|
|
162
|
|
|
|
|
|
|
$obj->process($input); |
|
163
|
|
|
|
|
|
|
|
|
164
|
|
|
|
|
|
|
Process Tags structure for fields defined in C<@fields> to output. |
|
165
|
|
|
|
|
|
|
|
|
166
|
|
|
|
|
|
|
Accepted C<$input> is L<Data::HTML::Form::Input>. |
|
167
|
|
|
|
|
|
|
|
|
168
|
|
|
|
|
|
|
Returns undef. |
|
169
|
|
|
|
|
|
|
|
|
170
|
|
|
|
|
|
|
=head2 C<process_css> |
|
171
|
|
|
|
|
|
|
|
|
172
|
|
|
|
|
|
|
$obj->process_css($input); |
|
173
|
|
|
|
|
|
|
|
|
174
|
|
|
|
|
|
|
Process CSS::Struct structure for output. |
|
175
|
|
|
|
|
|
|
|
|
176
|
|
|
|
|
|
|
Returns undef. |
|
177
|
|
|
|
|
|
|
|
|
178
|
|
|
|
|
|
|
=head1 ERRORS |
|
179
|
|
|
|
|
|
|
|
|
180
|
|
|
|
|
|
|
new(): |
|
181
|
|
|
|
|
|
|
From Tags::HTML::new(): |
|
182
|
|
|
|
|
|
|
Parameter 'css' must be a 'CSS::Struct::Output::*' class. |
|
183
|
|
|
|
|
|
|
Parameter 'tags' must be a 'Tags::Output::*' class. |
|
184
|
|
|
|
|
|
|
|
|
185
|
|
|
|
|
|
|
process(): |
|
186
|
|
|
|
|
|
|
From Tags::HTML::process(): |
|
187
|
|
|
|
|
|
|
Parameter 'tags' isn't defined. |
|
188
|
|
|
|
|
|
|
Input object must be a 'Data::HTML::Form::Input' instance. |
|
189
|
|
|
|
|
|
|
|
|
190
|
|
|
|
|
|
|
process_css(): |
|
191
|
|
|
|
|
|
|
From Tags::HTML::process_css(): |
|
192
|
|
|
|
|
|
|
Parameter 'css' isn't defined. |
|
193
|
|
|
|
|
|
|
Input object must be a 'Data::HTML::Form::Input' instance. |
|
194
|
|
|
|
|
|
|
|
|
195
|
|
|
|
|
|
|
=head1 EXAMPLE |
|
196
|
|
|
|
|
|
|
|
|
197
|
|
|
|
|
|
|
=for comment filename=create_and_print_input.pl |
|
198
|
|
|
|
|
|
|
|
|
199
|
|
|
|
|
|
|
use strict; |
|
200
|
|
|
|
|
|
|
use warnings; |
|
201
|
|
|
|
|
|
|
|
|
202
|
|
|
|
|
|
|
use CSS::Struct::Output::Indent; |
|
203
|
|
|
|
|
|
|
use Data::HTML::Form::Input; |
|
204
|
|
|
|
|
|
|
use Tags::HTML::Form::Input; |
|
205
|
|
|
|
|
|
|
use Tags::Output::Indent; |
|
206
|
|
|
|
|
|
|
|
|
207
|
|
|
|
|
|
|
# Object. |
|
208
|
|
|
|
|
|
|
my $css = CSS::Struct::Output::Indent->new; |
|
209
|
|
|
|
|
|
|
my $tags = Tags::Output::Indent->new( |
|
210
|
|
|
|
|
|
|
'xml' => 1, |
|
211
|
|
|
|
|
|
|
); |
|
212
|
|
|
|
|
|
|
my $obj = Tags::HTML::Form::Input->new( |
|
213
|
|
|
|
|
|
|
'css' => $css, |
|
214
|
|
|
|
|
|
|
'tags' => $tags, |
|
215
|
|
|
|
|
|
|
); |
|
216
|
|
|
|
|
|
|
|
|
217
|
|
|
|
|
|
|
# Data object for input. |
|
218
|
|
|
|
|
|
|
my $input = Data::HTML::Form::Input->new( |
|
219
|
|
|
|
|
|
|
'css_class' => 'form-input', |
|
220
|
|
|
|
|
|
|
); |
|
221
|
|
|
|
|
|
|
|
|
222
|
|
|
|
|
|
|
# Process input. |
|
223
|
|
|
|
|
|
|
$obj->process($input); |
|
224
|
|
|
|
|
|
|
$obj->process_css($input); |
|
225
|
|
|
|
|
|
|
|
|
226
|
|
|
|
|
|
|
# Print out. |
|
227
|
|
|
|
|
|
|
print "HTML:\n"; |
|
228
|
|
|
|
|
|
|
print $tags->flush; |
|
229
|
|
|
|
|
|
|
print "\n\n"; |
|
230
|
|
|
|
|
|
|
print "CSS:\n"; |
|
231
|
|
|
|
|
|
|
print $css->flush; |
|
232
|
|
|
|
|
|
|
|
|
233
|
|
|
|
|
|
|
# Output: |
|
234
|
|
|
|
|
|
|
# HTML: |
|
235
|
|
|
|
|
|
|
# <input class="form-input" type="text" /> |
|
236
|
|
|
|
|
|
|
# |
|
237
|
|
|
|
|
|
|
# CSS: |
|
238
|
|
|
|
|
|
|
# input.form-input[type=submit]:hover { |
|
239
|
|
|
|
|
|
|
# background-color: #45a049; |
|
240
|
|
|
|
|
|
|
# } |
|
241
|
|
|
|
|
|
|
# input.form-input[type=submit] { |
|
242
|
|
|
|
|
|
|
# width: 100%; |
|
243
|
|
|
|
|
|
|
# background-color: #4CAF50; |
|
244
|
|
|
|
|
|
|
# color: white; |
|
245
|
|
|
|
|
|
|
# padding: 14px 20px; |
|
246
|
|
|
|
|
|
|
# margin: 8px 0; |
|
247
|
|
|
|
|
|
|
# border: none; |
|
248
|
|
|
|
|
|
|
# border-radius: 4px; |
|
249
|
|
|
|
|
|
|
# cursor: pointer; |
|
250
|
|
|
|
|
|
|
# } |
|
251
|
|
|
|
|
|
|
# input.form-input { |
|
252
|
|
|
|
|
|
|
# width: 100%; |
|
253
|
|
|
|
|
|
|
# padding: 12px 20px; |
|
254
|
|
|
|
|
|
|
# margin: 8px 0; |
|
255
|
|
|
|
|
|
|
# display: inline-block; |
|
256
|
|
|
|
|
|
|
# border: 1px solid #ccc; |
|
257
|
|
|
|
|
|
|
# border-radius: 4px; |
|
258
|
|
|
|
|
|
|
# box-sizing: border-box; |
|
259
|
|
|
|
|
|
|
# } |
|
260
|
|
|
|
|
|
|
|
|
261
|
|
|
|
|
|
|
=head1 DEPENDENCIES |
|
262
|
|
|
|
|
|
|
|
|
263
|
|
|
|
|
|
|
L<Class::Utils>, |
|
264
|
|
|
|
|
|
|
L<Error::Pure>, |
|
265
|
|
|
|
|
|
|
L<Scalar::Util>, |
|
266
|
|
|
|
|
|
|
L<Tags::HTML>. |
|
267
|
|
|
|
|
|
|
|
|
268
|
|
|
|
|
|
|
=head1 REPOSITORY |
|
269
|
|
|
|
|
|
|
|
|
270
|
|
|
|
|
|
|
L<https://github.com/michal-josef-spacek/Tags-HTML-Form> |
|
271
|
|
|
|
|
|
|
|
|
272
|
|
|
|
|
|
|
=head1 AUTHOR |
|
273
|
|
|
|
|
|
|
|
|
274
|
|
|
|
|
|
|
Michal Josef Špaček L<mailto:skim@cpan.org> |
|
275
|
|
|
|
|
|
|
|
|
276
|
|
|
|
|
|
|
L<http://skim.cz> |
|
277
|
|
|
|
|
|
|
|
|
278
|
|
|
|
|
|
|
=head1 LICENSE AND COPYRIGHT |
|
279
|
|
|
|
|
|
|
|
|
280
|
|
|
|
|
|
|
© 2022 Michal Josef Špaček |
|
281
|
|
|
|
|
|
|
|
|
282
|
|
|
|
|
|
|
BSD 2-Clause License |
|
283
|
|
|
|
|
|
|
|
|
284
|
|
|
|
|
|
|
=head1 VERSION |
|
285
|
|
|
|
|
|
|
|
|
286
|
|
|
|
|
|
|
0.07 |
|
287
|
|
|
|
|
|
|
|
|
288
|
|
|
|
|
|
|
=cut |