lib/HTML/FormFu/Element/ContentButton.pm

filter: Statementstmt 100% 35 / 35 Branchbran 87.5% 7 / 8 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 7 / 7 Podpod n/a totaltotal 98.0% 49 / 50 CC 5 SCAR 8.2
CC
5
Cov
98%
_string_field
4.0
render_data_non_recursive
2.0
BEGIN
1.0
CRAP 2.3
« lib/HTML/FormFu/Filter/CompoundSprintf.pm ↑ Summary script/html_formfu_deploy.pl »
1 6 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
2  
3 package HTML::FormFu::Element::ContentButton;
4 6 $HTML::FormFu::Element::ContentButton::VERSION = '2.09';
5 # ABSTRACT: Button form field containing markup
6  
7 6 ▶use Moose;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 6 ▶use MooseX::Attribute::Chained;
Subroutine BEGIN: called CC=1 SCAR=0.0
9 6 extends "HTML::FormFu::Element";
10 6 with 'HTML::FormFu::Role::Element::Field',
11 'HTML::FormFu::Role::Element::SingleValueField';
12  
13 6 ▶use HTML::FormFu::Util qw( xml_escape process_attrs );
Subroutine BEGIN: called CC=1 SCAR=0.0
14  
15 6 __PACKAGE__->mk_output_accessors(qw( content ));
16  
17 6 has field_type => (
18 is => 'rw',
19 default => 'button',
20 lazy => 1,
21 traits => ['Chained'],
22 );
23  
24 6 ▶after BUILD => sub {
Subroutine __ANON__: called CC=1 SCAR=0.0
25 6 my ( $self, $args ) = @_;
26  
27 6 $self->layout_field_filename('field_layout_contentbutton_field');
28  
29 6 return;
30 6 };
31  
32 9 ▶sub render_data_non_recursive {
Subroutine render_data_non_recursive: called CC=2 SCAR=7.1
33 9 my ( $self, $args ) = @_;
34  
35 9 ▶ my $render = $self->SUPER::render_data_non_recursive(
Branch: 1 branch
BranchTrueFalseTotal
$args ? : 9 0 9
36 { field_type => $self->field_type,
37 content => xml_escape( $self->content ),
38 $args ? %$args : (),
39 } );
40  
41 9 return $render;
42 }
43  
44 8 ▶sub _string_field {
Subroutine _string_field: called CC=4 SCAR=13.9
45 8 my ( $self, $render ) = @_;
46  
47 # content_button template
48  
49 8 my $html = "<button";
50  
51 8 ▶ if ( defined $render->{nested_name} ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $render->{"nested_name"}) 7 1 8
52 7 $html .= sprintf qq{ name="%s"}, $render->{nested_name};
53 }
54  
55 8 $html .= sprintf qq{ type="%s"}, $render->{field_type};
56  
57 8 ▶ if ( defined $render->{value} ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $render->{"value"}) 2 6 8
58 2 $html .= sprintf qq{ value="%s"}, $render->{value};
59 }
60  
61 $html .= sprintf "%s>%s</button>",
62 process_attrs( $render->{attributes} ),
63 8 ▶ ( defined $render->{content} ? $render->{content} : '' ),
Branch: 1 branch
BranchTrueFalseTotal
defined $render->{'content'} ? : 3 5 8
64 ;
65  
66 8 return $html;
67 }
68  
69 6 __PACKAGE__->meta->make_immutable;
70  
71 6 1;
72  
73 __END__
« lib/HTML/FormFu/Filter/CompoundSprintf.pm ↑ Summary script/html_formfu_deploy.pl »