| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package HTML::FormHandler::Widget::ApplyRole; |
|
2
|
|
|
|
|
|
|
# ABSTRACT: role to apply widgets |
|
3
|
|
|
|
|
|
|
$HTML::FormHandler::Widget::ApplyRole::VERSION = '0.40067'; |
|
4
|
143
|
|
|
143
|
|
95390
|
use Moose::Role; |
|
|
143
|
|
|
|
|
261
|
|
|
|
143
|
|
|
|
|
1084
|
|
|
5
|
143
|
|
|
143
|
|
504161
|
use File::Spec; |
|
|
143
|
|
|
|
|
581
|
|
|
|
143
|
|
|
|
|
3489
|
|
|
6
|
143
|
|
|
143
|
|
505
|
use Class::MOP; |
|
|
143
|
|
|
|
|
177
|
|
|
|
143
|
|
|
|
|
2596
|
|
|
7
|
143
|
|
|
143
|
|
550
|
use Try::Tiny; |
|
|
143
|
|
|
|
|
288
|
|
|
|
143
|
|
|
|
|
8507
|
|
|
8
|
143
|
|
|
143
|
|
593
|
use Class::Load qw/ load_optional_class /; |
|
|
143
|
|
|
|
|
192
|
|
|
|
143
|
|
|
|
|
5359
|
|
|
9
|
143
|
|
|
143
|
|
572
|
use namespace::autoclean; |
|
|
143
|
|
|
|
|
293
|
|
|
|
143
|
|
|
|
|
1207
|
|
|
10
|
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
our $ERROR; |
|
12
|
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
sub apply_widget_role { |
|
14
|
3
|
|
|
3
|
0
|
59
|
my ( $self, $target, $widget_name, $dir ) = @_; |
|
15
|
|
|
|
|
|
|
|
|
16
|
3
|
|
|
|
|
15
|
my $render_role = $self->get_widget_role( $widget_name, $dir ); |
|
17
|
3
|
50
|
|
|
|
114
|
$render_role->meta->apply($target) if $render_role; |
|
18
|
|
|
|
|
|
|
} |
|
19
|
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
sub get_widget_role { |
|
21
|
2759
|
|
|
2759
|
0
|
4246
|
my ( $self, $widget_name, $dir ) = @_; |
|
22
|
2759
|
|
|
|
|
9862
|
my $widget_class = $self->widget_class($widget_name); |
|
23
|
2759
|
50
|
|
|
|
7409
|
my $ldir = $dir ? '::' . $dir . '::' : '::'; |
|
24
|
|
|
|
|
|
|
|
|
25
|
2759
|
|
|
|
|
70352
|
my $widget_ns = $self->widget_name_space; |
|
26
|
2759
|
|
|
|
|
4982
|
my @name_spaces = @$widget_ns; |
|
27
|
2759
|
|
|
|
|
4216
|
push @name_spaces, ('HTML::FormHandler::Widget', 'HTML::FormHandlerX::Widget'); |
|
28
|
2759
|
|
|
|
|
4354
|
my @classes; |
|
29
|
2759
|
100
|
|
|
|
6233
|
if ( $widget_class =~ s/^\+// ) |
|
30
|
|
|
|
|
|
|
{ |
|
31
|
2
|
|
|
|
|
5
|
push @classes, $widget_class; |
|
32
|
|
|
|
|
|
|
} |
|
33
|
2759
|
|
|
|
|
5749
|
foreach my $ns (@name_spaces) { |
|
34
|
5543
|
|
|
|
|
9941
|
push @classes, $ns . $ldir . $widget_class; |
|
35
|
|
|
|
|
|
|
} |
|
36
|
2759
|
|
|
|
|
3347
|
foreach my $try (@classes) { |
|
37
|
2782
|
100
|
|
|
|
14985
|
return $try if load_optional_class($try); |
|
38
|
|
|
|
|
|
|
} |
|
39
|
2
|
|
|
|
|
583
|
die "Can't find $dir widget $widget_class from " . join(", ", @name_spaces); |
|
40
|
|
|
|
|
|
|
} |
|
41
|
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
# this is for compatibility with widget names like 'radio_group' |
|
43
|
|
|
|
|
|
|
# RadioGroup, Textarea, etc. also work |
|
44
|
|
|
|
|
|
|
sub widget_class { |
|
45
|
2759
|
|
|
2759
|
0
|
3144
|
my ( $self, $widget ) = @_; |
|
46
|
2759
|
50
|
|
|
|
6974
|
return unless $widget; |
|
47
|
2759
|
100
|
|
|
|
7236
|
if($widget eq lc $widget) { |
|
48
|
3
|
|
|
|
|
27
|
$widget =~ s/^(\w{1})/\u$1/g; |
|
49
|
3
|
|
|
|
|
17
|
$widget =~ s/_(\w{1})/\u$1/g; |
|
50
|
|
|
|
|
|
|
} |
|
51
|
2759
|
|
|
|
|
3765
|
return $widget; |
|
52
|
|
|
|
|
|
|
} |
|
53
|
|
|
|
|
|
|
|
|
54
|
143
|
|
|
143
|
|
60421
|
use namespace::autoclean; |
|
|
143
|
|
|
|
|
1275
|
|
|
|
143
|
|
|
|
|
777
|
|
|
55
|
|
|
|
|
|
|
1; |
|
56
|
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
__END__ |
|
58
|
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
=pod |
|
60
|
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
=encoding UTF-8 |
|
62
|
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
=head1 NAME |
|
64
|
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
HTML::FormHandler::Widget::ApplyRole - role to apply widgets |
|
66
|
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
=head1 VERSION |
|
68
|
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
version 0.40067 |
|
70
|
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
=head1 AUTHOR |
|
72
|
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
FormHandler Contributors - see HTML::FormHandler |
|
74
|
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
|
76
|
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
This software is copyright (c) 2016 by Gerda Shank. |
|
78
|
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
This is free software; you can redistribute it and/or modify it under |
|
80
|
|
|
|
|
|
|
the same terms as the Perl 5 programming language system itself. |
|
81
|
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
=cut |