File Coverage

blib/lib/Templ/Tag/Filter.pm
Criterion Covered Total %
statement 27 29 93.1
branch 2 4 50.0
condition n/a
subroutine 8 8 100.0
pod 0 3 0.0
total 37 44 84.0


line stmt bran cond sub pod time code
1             package Templ::Tag::Filter;
2 1     1   5 use base 'Templ::Tag';
  1         2  
  1         85  
3              
4 1     1   9 use strict;
  1         2  
  1         26  
5 1     1   4 use warnings;
  1         2  
  1         26  
6              
7 1     1   5 use Templ::Util qw(default);
  1         2  
  1         49  
8 1     1   5 use Carp qw(croak);
  1         1  
  1         272  
9              
10             sub perl {
11 6     6 0 8 my $self = shift;
12 6         11 my $content = shift;
13 6         7 my $indent = shift;
14 6         9 my $append = shift;
15              
16 6         12 my $expr = $self->filter . "( $content )";
17 6 50       17 if ( default($indent) ne '' ) {
18 0         0 $expr = "indent( '$indent', $expr )";
19             }
20              
21 6         272 return "$append$expr;\n";
22             }
23              
24             sub check {
25 3     3 0 5 my $self = shift;
26 3         10 $self->SUPER::check();
27 3 50       8 if ( $self->filter() !~ m/^\w+$/ ) {
28 0         0 croak "Missing or malformed 'filter' for " . __PACKAGE__ . " object";
29             }
30             }
31              
32             sub filter {
33 9     9 0 13 my $self = shift;
34 9         25 return default $self->{'filter'};
35             }
36              
37             1;