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   37413 use strict; use utf8; use warnings FATAL => 'all';
  98     98   166  
  98     98   5265  
  98         44437  
  98         691  
  98         2065  
  98         2467  
  98         814  
  98         5283  
3 98     98   977 use parent 'DTL::Fast::Replacer';
  98         836  
  98         528  
4              
5 98     98   42384 use DTL::Fast::Context;
  98         183  
  98         16053  
6              
7             sub new
8             {
9 3344     3344 0 5261 my( $proto, %kwargs ) = @_;
10              
11 3344         4014 $kwargs{'chunks'} = [];
12            
13 3344         9178 return $proto->SUPER::new(%kwargs);
14             }
15              
16             sub add_chunk
17             {
18 6671     6671 0 5529 my( $self, $chunk ) = @_;
19            
20 6671 100       9645 push @{$self->{'chunks'}}, $chunk if defined $chunk;
  3810         5193  
21 6671         7990 return $self;
22             }
23              
24             sub render
25             {
26 4454     4454 0 3978 my( $self, $context, $global_safe ) = @_;
27              
28 4454   66     12236 $global_safe ||= $context->{'ns'}->[-1]->{'_dtl_safe'};
29            
30 4454         4678 my $result = [];
31            
32 4454         3422 foreach my $chunk (@{$self->{'chunks'}})
  4454         6894  
33             {
34 6122   100     12858 push @$result, $chunk->render($context, $global_safe) // '';
35             }
36            
37 4421         12065 return join '', @$result;
38             }
39              
40             1;