Zoom/FilterBuilder/Template.pm untested

filter: Statementstmt 0.0% 0 / 30 Branchbran 0.0% 0 / 4 Conditioncond 0.0% 0 / 3 MC/DCmcdc n/a Subroutinesub 0.0% 0 / 5 Podpod 0.0% 0 / 3 totaltotal 0.0% 0 / 45 SCAR 24.8
CC
3
Cov
0%
template_text
6.0
template_text_raw
6.0
_template_object
2.0
CRAP 12.0
1 package HTML::Zoom::FilterBuilder;
2  
3 use strictures 1;
4 use Template::Tiny;
5  
6 sub _template_object {
7 shift->{_template_object} ||= Template::Tiny->new;
8 }
9  
10 sub template_text {
11 my ($self, $vars) = @_;
12 my $parser = $self->_zconfig->parser;
13 my $tt = $self->_template_object;
14 $self->collect({
15 filter => sub {
16 $_->map(sub {
17 return $_ unless $_->{type} eq 'TEXT';
18 my $unescape = $parser->html_unescape($_->{raw});
19 $tt->process(\$unescape, $vars, \my $out);
20 return { %$_, raw => $parser->html_escape($out) }
21 })
22 },
23 passthrough => 1,
24 })
25 }
26  
27 sub template_text_raw {
28 my ($self, $vars) = @_;
29 my $tt = $self->_template_object;
30 my $parser = $self->_zconfig->parser;
31 $self->collect({
32 filter => sub {
33 $_->map(sub {
34 return $_ unless $_->{type} eq 'TEXT';
35 $tt->process(\($_->{raw}), $vars, \my $out);
36 return { %$_, raw => $out }
37 })
38 },
39 passthrough => 1,
40 })
41 }
42  
43 1;