lib/Template/Mustache/Token/Section.pm

filter: Statementstmt 90.3% 28 / 31 Branchbran 50.0% 6 / 12 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 5 / 5 Podpod 0.0% 0 / 1 totaltotal 79.5% 39 / 49 SCAR 20.1
CC
7
Cov
79%
render
9.0
BEGIN
1.0
BEGIN
1.0
CRAP 7.4
« lib/Template/Mustache/Token/Template.pm ↑ Summary lib/Template/Mustache/Token/Partial.pm »
1 package Template::Mustache::Token::Section;
2 22 our $AUTHORITY = 'cpan:YANICK';
3 # ABSTRACT: Object representing a Section block
4 22 $Template::Mustache::Token::Section::VERSION = '1.3.3';
5 22 ▶use Moo;
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 22 ▶use MooseX::MungeHas { has_ro => [ 'is_ro' ] };
Subroutine BEGIN: called CC=1 SCAR=0.0
8  
9 22 has_ro 'variable';
10 22 has_ro 'template';
11 22 has_ro 'inverse';
12 22 has_ro 'delimiters';
13 22 has_ro 'raw';
14  
15 22 ▶use Template::Mustache;
Subroutine BEGIN: called CC=1 SCAR=0.0
16  
17 sub render {
18 11 ▶ my( $self, $context, $partials, $indent ) = @_;
Subroutine render: called CC=7 SCAR=22.0
Pod undocumented
19  
20 11 my $cond = Template::Mustache::resolve_context( $self->variable, $context );
21  
22 11 ▶ if ( ref $cond eq 'CODE' ) {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $cond eq "CODE") 2 9 11
23 my $value=Template::Mustache->new(
24 delimiters => $self->delimiters,
25 template => $cond->(
26 $self->raw,
27 sub {
28 2 ▶ Template::Mustache->new( template=> shift )->parsed->render(
Subroutine __ANON__: called CC=1 SCAR=0.0
29 $context, $partials, $indent
30 ) }
31 )
32 2 )->parsed->render( $context, $partials );
33  
34 2 ▶ return '' if $self->inverse;
Branch: 1 branch
BranchTrueFalseTotal
if $self->inverse 0 2 2
35 2 return $value;
36 }
37  
38 9 ▶ if ( $self->inverse ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->inverse) 0 9 9
39 0 ▶ if ( ref $cond eq 'ARRAY' ) {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $cond eq 'ARRAY') { } 0 0 0
40 0 $cond = ! @$cond;
41 }else {
42 0 $cond = !$cond;
43 }
44 }
45  
46 9 ▶ return unless $cond;
Branch: 1 branch
BranchTrueFalseTotal
unless $cond 0 9 9
47  
48 9 ▶ return join '', map { $self->template->render( [ $_, @$context ], $partials ) }
Branch: 1 branch
BranchTrueFalseTotal
ref $cond eq 'ARRAY' ? : 0 9 9
49 ref $cond eq 'ARRAY' ? @$cond : ( $cond );
50 }
51  
52 22 1;
53  
54 __END__
55  
56 =pod
57  
58 =encoding UTF-8
59  
60 =head1 NAME
61  
62 Template::Mustache::Token::Section - Object representing a Section block
63  
64 =head1 VERSION
65  
66 version 1.3.3
67  
68 =head1 AUTHORS
69  
70 =over 4
71  
72 =item *
73  
74 Pieter van de Bruggen <pvande@cpan.org>
75  
76 =item *
77  
78 Yanick Champoux <yanick@cpan.org>
79  
80 =item *
81  
82 Ricardo Signes <rjbs@cpan.org>
83  
84 =back
85  
86 =head1 COPYRIGHT AND LICENSE
87  
88 This software is copyright (c) 2019, 2018, 2017, 2016, 2015, 2011 by Pieter van de Bruggen.
89  
90 This is free software; you can redistribute it and/or modify it under
91 the same terms as the Perl 5 programming language system itself.
92  
93 =cut
« lib/Template/Mustache/Token/Template.pm ↑ Summary lib/Template/Mustache/Token/Partial.pm »