File Coverage

blib/lib/DTL/Fast/Tag/Dump.pm
Criterion Covered Total %
statement 23 23 100.0
branch 2 2 100.0
condition n/a
subroutine 6 6 100.0
pod 0 2 0.0
total 31 33 93.9


line stmt bran cond sub pod time code
1             package DTL::Fast::Tag::Dump;
2 4     4   1467 use strict;
  4         8  
  4         90  
3 4     4   17 use utf8;
  4         6  
  4         18  
4 4     4   79 use warnings FATAL => 'all';
  4         7  
  4         113  
5 4     4   18 use parent 'DTL::Fast::Tag::Simple';
  4         7  
  4         19  
6              
7             $DTL::Fast::TAG_HANDLERS{dump} = __PACKAGE__;
8              
9             #@Override
10             sub parse_parameters
11             {
12 21     21 0 32 my $self = shift;
13              
14 21 100       64 die $self->get_parse_error("no variable specified for dumping") unless ($self->{parameter});
15 18         61 $self->{variables} = $self->parse_sources($self->{parameter});
16              
17 18         39 return $self;
18             }
19              
20             #@Override
21             sub render
22             {
23 18     18 0 29 my ($self, $context) = @_;
24              
25 18         89 require Data::Dumper;
26 18         36 my @result = ();
27 18         29 foreach my $variable (@{$self->{variables}})
  18         28  
28             {
29             push @result,
30             Data::Dumper->Dump(
31             [ $variable->render($context, 'safe') ],
32 21         192 [ 'context.'.$variable->{original} ]
33             )
34             ;
35             }
36              
37 18         925 return join "\n", @result;
38             }
39              
40             1;