line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package HTML::Shakan::Declare; |
2
|
2
|
|
|
2
|
|
69707
|
use strict; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
46
|
|
3
|
2
|
|
|
2
|
|
9
|
use warnings; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
57
|
|
4
|
2
|
|
|
2
|
|
664
|
use parent 'Exporter'; |
|
2
|
|
|
|
|
457
|
|
|
2
|
|
|
|
|
9
|
|
5
|
2
|
|
|
2
|
|
696
|
use HTML::Shakan (); |
|
2
|
|
|
|
|
170
|
|
|
2
|
|
|
|
|
348
|
|
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
our @EXPORT = qw(form get); |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
sub import { |
10
|
2
|
|
|
2
|
|
23
|
my $class = shift; |
11
|
2
|
|
|
|
|
173
|
__PACKAGE__->export_to_level(1); |
12
|
2
|
|
|
|
|
2262
|
HTML::Shakan::Fields->export_to_level(1); |
13
|
|
|
|
|
|
|
} |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
our $FORMS; |
16
|
|
|
|
|
|
|
sub form ($@) { ## no critic. |
17
|
2
|
|
|
2
|
1
|
8
|
my ($name, @fields) = @_; |
18
|
2
|
|
|
|
|
7
|
my $pkg = caller(0); |
19
|
2
|
|
|
|
|
11
|
$FORMS->{$pkg}->{$name} = \@fields; |
20
|
|
|
|
|
|
|
} |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
sub get { |
23
|
3
|
|
|
3
|
1
|
962
|
my ($class, $name, %args) = @_; |
24
|
3
|
|
33
|
|
|
22
|
$class = ref $class || $class; |
25
|
|
|
|
|
|
|
return HTML::Shakan->new( |
26
|
3
|
|
|
|
|
31
|
fields => $FORMS->{$class}->{$name}, |
27
|
|
|
|
|
|
|
%args, |
28
|
|
|
|
|
|
|
); |
29
|
|
|
|
|
|
|
} |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
1; |
32
|
|
|
|
|
|
|
__END__ |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
=head1 NAME |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
HTML::Shakan::Declare - declare the form |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
=head1 SYNOPSIS |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
# declare |
41
|
|
|
|
|
|
|
{ |
42
|
|
|
|
|
|
|
package My::Form; |
43
|
|
|
|
|
|
|
use HTML::Shakan::Declare; |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
form 'add' => ( |
46
|
|
|
|
|
|
|
TextField( |
47
|
|
|
|
|
|
|
name => 'name', |
48
|
|
|
|
|
|
|
required => 1, |
49
|
|
|
|
|
|
|
), |
50
|
|
|
|
|
|
|
TextField( |
51
|
|
|
|
|
|
|
name => 'email', |
52
|
|
|
|
|
|
|
required => 1, |
53
|
|
|
|
|
|
|
), |
54
|
|
|
|
|
|
|
); |
55
|
|
|
|
|
|
|
} |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
# use it |
58
|
|
|
|
|
|
|
{ |
59
|
|
|
|
|
|
|
my $form = My::Form->get( |
60
|
|
|
|
|
|
|
'add' => ( |
61
|
|
|
|
|
|
|
request => CGI->new, |
62
|
|
|
|
|
|
|
) |
63
|
|
|
|
|
|
|
); |
64
|
|
|
|
|
|
|
$form->render; |
65
|
|
|
|
|
|
|
} |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
=head1 DESCRIPTION |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
This module supports to generate form using declare style. |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
=head1 FUNCTIONS |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
This module exports L<HTML::Shakan::Fields>'s exported functions and following functions. |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
=over 4 |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
=item form($name, \@fields) |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
Register new form named I<$name> with C<<\@fields>>. |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
=back |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
=head1 EXPORTED METHODS |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
=over 4 |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
=item Your::Form::Class->get($name[, %args]) |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
Now, your form class provides I< get > method. This method returns instance of L<HTML::Shakan>. |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
=back |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
=head1 AUTHORS |
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
Tokuhiro Matsuno |
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
=head1 SEE ALSO |
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
L<HTML::Shakan> |
100
|
|
|
|
|
|
|
|