Tmojo/Filters.pm untested

filter: Statementstmt 0.0% 0 / 31 Branchbran 0.0% 0 / 4 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 0.0% 0 / 5 Podpod 0.0% 0 / 3 totaltotal 0.0% 0 / 43 CC 3 SCAR 18.4
CC
3
Cov
0%
reduce_indentation
12.0
html_attribute
2.0
html_content
2.0
CRAP 6.3
1 ###########################################################################
2 # Copyright 2004 Lab-01 LLC <http://lab-01.com/>
3 #
4 # Licensed under the Apache License, Version 2.0 (the "License");
5 # you may not use this file except in compliance with the License.
6 # You may obtain a copy of the License at
7 #
8 # http://www.apache.org/licenses/LICENSE-2.0
9 #
10 # Unless required by applicable law or agreed to in writing, software
11 # distributed under the License is distributed on an "AS IS" BASIS,
12 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 # See the License for the specific language governing permissions and
14 # limitations under the License.
15 #
16 # Tmojo(tm) is a trademark of Lab-01 LLC.
17 ###########################################################################
18  
19 package HTML::Tmojo::Filters;
20  
21 use strict;
22 require Exporter;
23 our @ISA = qw(Exporter);
24 our @EXPORT = qw(
25 html_attribute
26 html_content
27 reduce_indentation
28 );
29  
30 sub html_attribute {
31 my ($val) = @_;
32
33 for ($val) {
34 s/'/&apos;/g;
35 s/"/&quot;/g;
36 }
37
38 return $val;
39 }
40  
41 sub html_content {
42 my ($val) = @_;
43
44 for ($val) {
45 s/&/&amp;/g;
46 s/</&lt;/g;
47 s/>/&gt;/g;
48 }
49
50 return $val;
51 }
52  
53 sub reduce_indentation {
54 my $text = shift;
55 my %args = @_;
56
57 if ($args{tabs_to_spaces} ne '') {
58 $text =~ s/\t/' ' x $args{tabs_to_spaces}/eg;
59 }
60
61 $text =~ /^(\s+)/;
62 my $remove = $1;
63
64 my @lines = split /\n/, $text;
65 foreach my $line (@lines) {
66 $line =~ s/^$remove//;
67 if ($args{base_indentation} ne '') {
68 $line = $args{base_indentation} . $line;
69 }
70 }
71
72 return join("\n", @lines);
73 }
74  
75  
76 1;