File Coverage

lib/HTML/FormWidgets/Label.pm
Criterion Covered Total %
statement 23 31 74.1
branch 4 8 50.0
condition n/a
subroutine 5 5 100.0
pod 2 2 100.0
total 34 46 73.9


line stmt bran cond sub pod time code
1             package HTML::FormWidgets::Label;
2              
3 1     1   822 use strict;
  1         2  
  1         28  
4 1     1   6 use warnings;
  1         2  
  1         31  
5 1     1   5 use parent 'HTML::FormWidgets';
  1         2  
  1         6  
6              
7             __PACKAGE__->mk_accessors( qw( dropcap ) );
8              
9             sub init {
10 5     5 1 11    my ($self, $args) = @_;
11              
12 5         15    $self->class ( 'label_text' );
13 5         35    $self->container( 0 );
14 5         32    $self->dropcap ( 0 );
15 5         33    $self->text ( undef );
16 5         27    return;
17             }
18              
19             sub render_field {
20 5     5 1 7    my ($self, $args) = @_; my $text = $self->text;
  5         18  
21              
22 5 50       25    defined $text or return; $text =~ s{ \A \n }{}msx;
  5         10  
23              
24 5 50       14    if ($self->dropcap) {
25 0         0       my $markup;
26              
27 0 0       0       if ($text =~ m{ \A (\<[A-Za-z0-9]+\>) }mx) {
28 0         0          $markup = $1;
29 0         0          $markup .= $self->hacc->span( { class => q(dropcap) },
30                                                    substr $text, length $1, 1 );
31 0         0          $markup .= substr $text, (length $1) + 1;
32                   }
33                   else {
34 0         0          $markup = $self->hacc->span( { class => q(dropcap) },
35                                                    substr $text, 0, 1 );
36 0         0          $markup .= substr $text, 1;
37                   }
38              
39 0         0       $text = $markup;
40                }
41              
42 5 100       31    $args = { class => $self->class }; $self->id and $args->{id} = $self->id;
  5         32  
43              
44 5         1107    return $self->hacc->span( $args, $text );
45             }
46              
47             1;
48              
49             # Local Variables:
50             # mode: perl
51             # tab-width: 3
52             # End:
53