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.40068'; |
4
|
145
|
|
|
145
|
|
115148
|
use Moose::Role; |
|
145
|
|
|
|
|
2094
|
|
|
145
|
|
|
|
|
1432
|
|
5
|
145
|
|
|
145
|
|
774489
|
use File::Spec; |
|
145
|
|
|
|
|
406
|
|
|
145
|
|
|
|
|
4028
|
|
6
|
145
|
|
|
145
|
|
803
|
use Class::MOP; |
|
145
|
|
|
|
|
351
|
|
|
145
|
|
|
|
|
3222
|
|
7
|
145
|
|
|
145
|
|
825
|
use Try::Tiny; |
|
145
|
|
|
|
|
366
|
|
|
145
|
|
|
|
|
10095
|
|
8
|
145
|
|
|
145
|
|
927
|
use Class::Load qw/ load_optional_class /; |
|
145
|
|
|
|
|
360
|
|
|
145
|
|
|
|
|
6393
|
|
9
|
145
|
|
|
145
|
|
962
|
use namespace::autoclean; |
|
145
|
|
|
|
|
369
|
|
|
145
|
|
|
|
|
5170
|
|
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
our $ERROR; |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
sub apply_widget_role { |
14
|
3
|
|
|
3
|
0
|
72
|
my ( $self, $target, $widget_name, $dir ) = @_; |
15
|
|
|
|
|
|
|
|
16
|
3
|
|
|
|
|
17
|
my $render_role = $self->get_widget_role( $widget_name, $dir ); |
17
|
3
|
50
|
|
|
|
182
|
$render_role->meta->apply($target) if $render_role; |
18
|
|
|
|
|
|
|
} |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
sub get_widget_role { |
21
|
2777
|
|
|
2777
|
0
|
8728
|
my ( $self, $widget_name, $dir ) = @_; |
22
|
2777
|
|
|
|
|
10466
|
my $widget_class = $self->widget_class($widget_name); |
23
|
2777
|
50
|
|
|
|
10889
|
my $ldir = $dir ? '::' . $dir . '::' : '::'; |
24
|
|
|
|
|
|
|
|
25
|
2777
|
|
|
|
|
79820
|
my $widget_ns = $self->widget_name_space; |
26
|
2777
|
|
|
|
|
8247
|
my @name_spaces = @$widget_ns; |
27
|
2777
|
|
|
|
|
7265
|
push @name_spaces, ('HTML::FormHandler::Widget', 'HTML::FormHandlerX::Widget'); |
28
|
2777
|
|
|
|
|
5292
|
my @classes; |
29
|
2777
|
100
|
|
|
|
9656
|
if ( $widget_class =~ s/^\+// ) |
30
|
|
|
|
|
|
|
{ |
31
|
2
|
|
|
|
|
9
|
push @classes, $widget_class; |
32
|
|
|
|
|
|
|
} |
33
|
2777
|
|
|
|
|
6986
|
foreach my $ns (@name_spaces) { |
34
|
5587
|
|
|
|
|
16216
|
push @classes, $ns . $ldir . $widget_class; |
35
|
|
|
|
|
|
|
} |
36
|
2777
|
|
|
|
|
6517
|
foreach my $try (@classes) { |
37
|
2807
|
100
|
|
|
|
25963
|
return $try if load_optional_class($try); |
38
|
|
|
|
|
|
|
} |
39
|
2
|
|
|
|
|
1217
|
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
|
2777
|
|
|
2777
|
0
|
7315
|
my ( $self, $widget ) = @_; |
46
|
2777
|
50
|
|
|
|
10491
|
return unless $widget; |
47
|
2777
|
100
|
|
|
|
10623
|
if($widget eq lc $widget) { |
48
|
3
|
|
|
|
|
31
|
$widget =~ s/^(\w{1})/\u$1/g; |
49
|
3
|
|
|
|
|
22
|
$widget =~ s/_(\w{1})/\u$1/g; |
50
|
|
|
|
|
|
|
} |
51
|
2777
|
|
|
|
|
6808
|
return $widget; |
52
|
|
|
|
|
|
|
} |
53
|
|
|
|
|
|
|
|
54
|
145
|
|
|
145
|
|
64897
|
use namespace::autoclean; |
|
145
|
|
|
|
|
367
|
|
|
145
|
|
|
|
|
727
|
|
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.40068 |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
=head1 AUTHOR |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
FormHandler Contributors - see HTML::FormHandler |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
This software is copyright (c) 2017 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 |