File Coverage

blib/lib/DTL/Fast/Tag/Verbatim.pm
Criterion Covered Total %
statement 29 30 96.6
branch 4 4 100.0
condition 2 2 100.0
subroutine 8 9 88.8
pod 0 4 0.0
total 43 49 87.7


line stmt bran cond sub pod time code
1             package DTL::Fast::Tag::Verbatim;
2 3     3   1287 use strict;
  3         6  
  3         79  
3 3     3   12 use utf8;
  3         70  
  3         14  
4 3     3   66 use warnings FATAL => 'all';
  3         5  
  3         87  
5 3     3   13 use parent 'DTL::Fast::Tag';
  3         5  
  3         20  
6             $DTL::Fast::TAG_HANDLERS{verbatim} = __PACKAGE__;
7              
8 3     3   177 use DTL::Fast::Text;
  3         5  
  3         620  
9              
10             #@Override
11 0     0 0 0 sub get_close_tag {return 'endverbatim';}
12              
13             #@Override
14             sub parse_parameters
15             {
16 22     22 0 42 my $self = shift;
17 22         68 $self->{contents} = DTL::Fast::Text->new();
18             $self->{last_tag} = $self->{parameter} ?
19 22 100       80 qr/\Qendverbatim\E\s+\Q$self->{parameter}\E/
20             : 'endverbatim';
21 22         65 return $self;
22             }
23              
24             #@Override
25             sub parse_next_chunk
26             {
27 130     130 0 187 my $self = shift;
28 130         173 my $chunk = shift @{$self->{raw_chunks}};
  130         232  
29 130   100     600 my $chunk_lines = scalar (my @tmp = $chunk =~ /(\n)/g ) || 0;
30              
31 130 100       585 if ($chunk =~ /^\{\%\s*$self->{last_tag}\s*\%\}$/six)
32             {
33 22         49 $self->{raw_chunks} = [ ]; # this stops parsing
34             }
35             else
36             {
37 108         292 $self->{contents}->append($chunk);
38             }
39              
40 130         191 $DTL::Fast::Template::CURRENT_TEMPLATE_LINE += $chunk_lines;
41              
42 130         353 return;
43             }
44              
45             #@Override
46             sub render
47             {
48 11     11 0 35 return shift->{contents}->render(shift);
49             }
50              
51             1;