File Coverage

blib/lib/HTML/ElementRaw.pm
Criterion Covered Total %
statement 6 22 27.2
branch 0 6 0.0
condition 0 3 0.0
subroutine 2 12 16.6
pod 10 10 100.0
total 18 53 33.9


line stmt bran cond sub pod time code
1             package HTML::ElementRaw;
2              
3             # Allow raw html as content so that special characters
4             # do not get encoded. The string is incorporated as part
5             # of the start tag in order to bypass the regular HTML::Element
6             # encoding.
7              
8 1     1   644 use strict;
  1         1  
  1         38  
9 1     1   5 use vars qw($VERSION @ISA);
  1         1  
  1         373  
10              
11             require HTML::Element;
12              
13             @ISA = qw(HTML::Element);
14              
15             $VERSION = '1.18';
16              
17             # Whole lotta overrides
18             #
19             # Have to store the string somewhere besides _content, because
20             # traverse looks in the attribute directly rather than calling
21             # content().
22              
23             sub push_content {
24             # Flatten elements into an HTML string if found,
25             # otherwise just slap the text in.
26 0 0   0 1   my @text = map(defined (ref $_ ? $_->as_HTML : $_) ? $_ : '', @_);
    0          
27 0           shift->{_string}[0] .= join('',@text);
28             }
29             sub insert_element {
30 0     0 1   push_content(@_);
31             }
32             sub starttag {
33 0     0 1   shift->{_string}[0];
34             }
35             sub as_HTML {
36 0     0 1   starttag(@_);
37             }
38              
39             # These become degenerate
40 0     0 1   sub endtag { return }
41 0     0 1   sub pos { return }
42 0     0 1   sub attr { return }
43 0     0 1   sub content { return }
44 0     0 1   sub tag { return }
45              
46             sub new {
47 0     0 1   my $that = shift;
48 0   0       my $class = ref($that) || $that;
49             # The tag type does not get displayed. We keep it
50             # around anyway, just in case.
51 0 0         my @args = @_ ? @_ : 'p';
52 0           my $self = new HTML::Element @args;
53 0           bless $self,$class;
54 0           $self;
55             }
56              
57             1;
58             __END__