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   1423 use strict; use utf8; use warnings FATAL => 'all';
  3     3   5  
  3     3   78  
  3         12  
  3         5  
  3         13  
  3         69  
  3         4  
  3         114  
3 3     3   12 use parent 'DTL::Fast::Tag';
  3         2  
  3         21  
4             $DTL::Fast::TAG_HANDLERS{'verbatim'} = __PACKAGE__;
5              
6 3     3   212 use DTL::Fast::Text;
  3         4  
  3         842  
7              
8             #@Override
9 0     0 0 0 sub get_close_tag{return 'endverbatim';}
10              
11             #@Override
12             sub parse_parameters
13             {
14 22     22 0 29 my $self = shift;
15 22         66 $self->{'contents'} = DTL::Fast::Text->new();
16 22 100       80 $self->{'last_tag'} = $self->{'parameter'} ?
17             qr/\Qendverbatim\E\s+\Q$self->{'parameter'}\E/
18             : 'endverbatim';
19 22         45 return $self;
20             }
21              
22             #@Override
23             sub parse_next_chunk
24             {
25 130     130 0 112 my $self = shift;
26 130         90 my $chunk = shift @{$self->{'raw_chunks'}};
  130         180  
27 130   100     629 my $chunk_lines = scalar (my @tmp = $chunk =~ /(\n)/g ) || 0;
28            
29 130 100       532 if( $chunk =~ /^\{\%\s*$self->{'last_tag'}\s*\%\}$/six )
30             {
31 22         41 $self->{'raw_chunks'} = []; # this stops parsing
32             }
33             else
34             {
35 108         255 $self->{'contents'}->append($chunk);
36             }
37              
38 130         122 $DTL::Fast::Template::CURRENT_TEMPLATE_LINE += $chunk_lines;
39            
40 130         328 return;
41             }
42              
43             #@Override
44             sub render
45             {
46 11     11 0 30 return shift->{'contents'}->render(shift);
47             }
48              
49             1;