File Coverage

lib/HTML/FormWidgets/Image.pm
Criterion Covered Total %
statement 22 22 100.0
branch 4 8 50.0
condition 0 2 0.0
subroutine 5 5 100.0
pod 2 2 100.0
total 33 39 84.6


line stmt bran cond sub pod time code
1             package HTML::FormWidgets::Image;
2              
3 1     1   774 use strict;
  1         2  
  1         38  
4 1     1   6 use warnings;
  1         2  
  1         34  
5 1     1   7 use parent 'HTML::FormWidgets';
  1         2  
  1         7  
6              
7             __PACKAGE__->mk_accessors( qw( fhelp subtype ) );
8              
9             sub init {
10 1     1 1 2    my ($self, $args) = @_;
11              
12 1         6    $self->fhelp ( q() );
13 1         7    $self->subtype( q(normal) );
14 1         10    $self->tiptype( q(normal) );
15 1         6    return;
16             }
17              
18             sub render_field {
19 1     1 1 3    my ($self, $args) = @_; my $hacc = $self->hacc;
  1         6  
20              
21                my $src = 'http:' eq (substr $self->text, 0, 5)
22 1 50 0     6            ? $self->text : ($self->options->{assets} // q()).$self->text;
23              
24 1         14    $args = { alt => $self->fhelp, src => $src };
25              
26 1 50       12    $self->class and $args->{class} = $self->class;
27 1 50       9    $self->id and $args->{id } = $self->id;
28              
29 1 50       9    $self->subtype eq 'icon' and return $hacc->span( $args );
30              
31 1         18    return $hacc->img( $args );
32             }
33              
34             1;
35              
36             # Local Variables:
37             # mode: perl
38             # tab-width: 3
39             # End:
40