File Coverage

blib/lib/DTL/Fast/Renderer.pm
Criterion Covered Total %
statement 29 29 100.0
branch 2 2 100.0
condition 4 5 80.0
subroutine 8 8 100.0
pod 0 3 0.0
total 43 47 91.4


line stmt bran cond sub pod time code
1             package DTL::Fast::Renderer;
2 98     98   60715 use strict; use utf8; use warnings FATAL => 'all';
  98     98   183  
  98     98   4087  
  98         75547  
  98         2010  
  98         1680  
  98         2856  
  98         2663  
  98         5901  
3 98     98   1617 use parent 'DTL::Fast::Replacer';
  98         173  
  98         4163  
4              
5 98     98   60706 use DTL::Fast::Context;
  98         269  
  98         21906  
6              
7             sub new
8             {
9 3344     3344 0 9062 my( $proto, %kwargs ) = @_;
10              
11 3344         6533 $kwargs{'chunks'} = [];
12            
13 3344         13309 return $proto->SUPER::new(%kwargs);
14             }
15              
16             sub add_chunk
17             {
18 6671     6671 0 9458 my( $self, $chunk ) = @_;
19            
20 6671 100       14805 push @{$self->{'chunks'}}, $chunk if defined $chunk;
  3810         8316  
21 6671         14416 return $self;
22             }
23              
24             sub render
25             {
26 4454     4454 0 6853 my( $self, $context, $global_safe ) = @_;
27              
28 4454   66     16945 $global_safe ||= $context->{'ns'}->[-1]->{'_dtl_safe'};
29            
30 4454         6955 my $result = [];
31            
32 4454         6030 foreach my $chunk (@{$self->{'chunks'}})
  4454         10385  
33             {
34 6122   100     18879 push @$result, $chunk->render($context, $global_safe) // '';
35             }
36            
37 4421         17956 return join '', @$result;
38             }
39              
40             1;