lib/HTML/FormFu/Element/ContentButton.pm

filter: Statementstmt 100% 32 / 32 Branchbran 83.3% 5 / 6 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 7 / 7 Podpod n/a totaltotal 97.7% 44 / 45 SCAR 13.9
CC
4
Cov
97%
_string_field
3.0
render_data_non_recursive
2.0
BEGIN
1.0
CRAP 4.0
« lib/HTML/FormFu/Upload.pm ↑ Summary lib/HTML/FormFu/Constraint/DateTime.pm »
1 3 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
2  
3 package HTML::FormFu::Element::ContentButton;
4 3 $HTML::FormFu::Element::ContentButton::VERSION = '2.06';
5 # ABSTRACT: Button form field containing markup
6  
7 3 ▶use Moose;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 3 ▶use MooseX::Attribute::Chained;
Subroutine BEGIN: called CC=1 SCAR=0.0
9 3 extends "HTML::FormFu::Element";
10 3 with 'HTML::FormFu::Role::Element::Field',
11 'HTML::FormFu::Role::Element::SingleValueField';
12  
13 3 ▶use HTML::FormFu::Util qw( xml_escape process_attrs );
Subroutine BEGIN: called CC=1 SCAR=0.0
14  
15 3 __PACKAGE__->mk_output_accessors(qw( content ));
16  
17 3 has field_type => (
18 is => 'rw',
19 default => 'button',
20 lazy => 1,
21 traits => ['Chained'],
22 );
23  
24 after BUILD => sub {
25 5 ▶ my ( $self, $args ) = @_;
Subroutine __ANON__: called CC=1 SCAR=0.0
26  
27 5 $self->layout_field_filename('field_layout_contentbutton_field');
28  
29 5 return;
30 3 };
31  
32 sub render_data_non_recursive {
33 7 ▶ my ( $self, $args ) = @_;
Subroutine render_data_non_recursive: called CC=2 SCAR=7.1
34  
35 7 ▶ my $render = $self->SUPER::render_data_non_recursive(
Branch: 1 branch
BranchTrueFalseTotal
$args ? : 7 0 7
36 { field_type => $self->field_type,
37 content => xml_escape( $self->content ),
38 $args ? %$args : (),
39 } );
40  
41 7 return $render;
42 }
43  
44 sub _string_field {
45 7 ▶ my ( $self, $render ) = @_;
Subroutine _string_field: called CC=3 SCAR=11.0
46  
47 # content_button template
48  
49 my $html .= sprintf qq{<button name="%s" type="%s"},
50 $render->{nested_name},
51 $render->{field_type},
52 7 ;
53  
54 7 ▶ if ( defined $render->{value} ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $render->{"value"}) 2 5 7
55 2 $html .= sprintf qq{ value="%s"}, $render->{value};
56 }
57  
58 $html .= sprintf "%s>%s</button>",
59 process_attrs( $render->{attributes} ),
60 7 ▶ ( defined $render->{content} ? $render->{content} : '' ),
Branch: 1 branch
BranchTrueFalseTotal
defined $render->{'content'} ? : 2 5 7
61 ;
62  
63 7 return $html;
64 }
65  
66 3 __PACKAGE__->meta->make_immutable;
67  
68 3 1;
69  
70 __END__
71  
72 =pod
73  
74 =encoding UTF-8
75  
76 =head1 NAME
77  
78 HTML::FormFu::Element::ContentButton - Button form field containing markup
79  
80 =head1 VERSION
81  
82 version 2.06
83  
84 =head1 SYNOPSIS
85  
86 ---
87 elements:
88 type: ContentButton
89 name: foo
90 content: '<img href="/foo.png" />'
91 field_type: Submit
92  
93 =head1 DESCRIPTION
94  
95 content_button form field, rendered using provided markup.
96  
97 =head1 METHODS
98  
99 =head2 content
100  
101 =head2 field_type
102  
103 =head1 SEE ALSO
104  
105 Is a sub-class of, and inherits methods from
106 L<HTML::FormFu::Role::Element::Field>,
107 L<HTML::FormFu::Element>
108  
109 L<HTML::FormFu>
110  
111 =head1 AUTHOR
112  
113 Carl Franks, C<cfranks@cpan.org>
114  
115 =head1 LICENSE
116  
117 This library is free software, you can redistribute it and/or modify it under
118 the same terms as Perl itself.
119  
120 =head1 AUTHOR
121  
122 Carl Franks <cpan@fireartist.com>
123  
124 =head1 COPYRIGHT AND LICENSE
125  
126 This software is copyright (c) 2018 by Carl Franks.
127  
128 This is free software; you can redistribute it and/or modify it under
129 the same terms as the Perl 5 programming language system itself.
130  
131 =cut
« lib/HTML/FormFu/Upload.pm ↑ Summary lib/HTML/FormFu/Constraint/DateTime.pm »