File Coverage

blib/lib/HTML/Template/Compiled/Plugin/HTML2.pm
Criterion Covered Total %
statement 21 21 100.0
branch 1 2 50.0
condition n/a
subroutine 6 6 100.0
pod 0 2 0.0
total 28 31 90.3


line stmt bran cond sub pod time code
1             package HTML::Template::Compiled::Plugin::HTML2;
2              
3             # ABSTRACT: Do not escape all HTML entities
4              
5 1     1   1317 use strict;
  1         3  
  1         44  
6 1     1   7 use warnings;
  1         2  
  1         33  
7              
8 1     1   5 use HTML::Template::Compiled;
  1         2  
  1         8  
9             HTML::Template::Compiled->register(__PACKAGE__);
10              
11 1     1   867 use HTML::Entities;
  1         5996  
  1         266  
12              
13             our $VERSION = '0.01';
14              
15             sub register{
16 1     1 0 13 my ($class) = @_;
17 1         5 my %plugs = (
18             escape => {
19             HTML_WITHOUT_NBSP => \&escape_html,
20             },
21             );
22              
23 1         3 return \%plugs;
24             }
25              
26             sub escape_html {
27 6     6 0 11421 my ($str) = @_;
28              
29 6 50       18 return $str unless defined $str;
30              
31 6         19 $str = HTML::Entities::encode_entities( $str );
32 6         133 $str =~ s! ! !g;
33 6         14 $str =~ s!<br />!
!g;
34              
35             #$str =~ s/&/&/g;
36             #$str =~ s/"/"/g;
37             #$str =~ s/'/'/g;
38             #$str =~ s/>/>/g;
39             #$str =~ s/
40              
41 6         161 return $str;
42             }
43              
44             1;
45              
46             __END__