lib/Template/Mustache/Token/Variable.pm

filter: Statementstmt 96.9% 32 / 33 Branchbran 83.3% 5 / 6 Conditioncond 50.0% 1 / 2 MC/DCmcdc 0.0% 0 / 1 Subroutinesub 87.5% 7 / 8 Podpod 0.0% 0 / 1 totaltotal 88.2% 45 / 51 SCAR 16.1
CC
5
Cov
93%
render
5.0
__ANON__
2.0
BEGIN
1.0
CRAP 5.0
« lib/Template/Mustache/Token/Partial.pm ↑ Summary lib/Template/Mustache/Token/Verbatim.pm »
1 package Template::Mustache::Token::Variable;
2 23 our $AUTHORITY = 'cpan:YANICK';
3 # ABSTRACT: Object representing a Variable block
4 23 $Template::Mustache::Token::Variable::VERSION = '1.3.3';
5 23 ▶use Escape::Houdini qw/ escape_html /;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 23 ▶use Scalar::Util qw/ looks_like_number /;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 23 ▶use Math::BigFloat;
Subroutine BEGIN: called CC=1 SCAR=0.0
8  
9 23 ▶use Moo;
Subroutine BEGIN: called CC=1 SCAR=0.0
10  
11 use MooseX::MungeHas {
12 23 has_ro => [ 'is_ro' ] ,
13 has_rw => [ 'is_rw' ] ,
14 23 ▶};
Subroutine BEGIN: called CC=1 SCAR=0.0
15  
16 23 has_ro 'name';
17  
18 has escape => (
19 is => 'rw',
20 0 ▶ lazy => 1, default => sub { 1 },
Subroutine __ANON__: not called CC=1 SCAR=6.9
21 23 predicate => 1,
22 );
23  
24 sub render {
25 63 ▶ my( $self, $context,$partials, $indent ) = @_;
Subroutine render: called CC=5 SCAR=16.1
Pod undocumented
26  
27 63 ▶ my $value =
Condition50%1/2
Template::Mustache::resolve_context($self->name, $context) // ""
l!l
630
MC/DC0%0/1
Template::Mustache::resolve_context($self->name, $context) // ""
Template::Mustache::resolve_context($self->name, $context)
Truth table50%1/2
A
A= Template::Mustache::resolve_context($self->name, $context)
Aresult
11
00
28 Template::Mustache::resolve_context( $self->name, $context ) // '';
29  
30 63 ▶ if( ref $value eq 'CODE' ) {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $value eq "CODE") 2 61 63
31 $value = $value->(
32 2 ▶ sub { Template::Mustache->new( template=> shift )->parsed->render( $context, $partials, $indent ) }
Subroutine __ANON__: called CC=1 SCAR=0.0
33 2 );
34 2 my $template = Template::Mustache->new( template => $value )->parsed;
35 2 $template->escape($self->escape);
36 2 $value = $template->render(
37 $context, $partials, $indent
38 );
39 }
40  
41 63 ▶ eval { $value = escape_html($value) } if $self->escape;
Branch: 1 branch
BranchTrueFalseTotal
if $self->escape 63 0 63
42  
43 63 ▶ $value = Math::BigFloat->new($value)->bstr if looks_like_number($value);
Branch: 1 branch
BranchTrueFalseTotal
if &looks_like_number($value) 4 59 63
44  
45 63 return $value;
46 }
47  
48 23 1;
49  
50 __END__
51  
52 =pod
53  
54 =encoding UTF-8
55  
56 =head1 NAME
57  
58 Template::Mustache::Token::Variable - Object representing a Variable block
59  
60 =head1 VERSION
61  
62 version 1.3.3
63  
64 =head1 AUTHORS
65  
66 =over 4
67  
68 =item *
69  
70 Pieter van de Bruggen <pvande@cpan.org>
71  
72 =item *
73  
74 Yanick Champoux <yanick@cpan.org>
75  
76 =item *
77  
78 Ricardo Signes <rjbs@cpan.org>
79  
80 =back
81  
82 =head1 COPYRIGHT AND LICENSE
83  
84 This software is copyright (c) 2019, 2018, 2017, 2016, 2015, 2011 by Pieter van de Bruggen.
85  
86 This is free software; you can redistribute it and/or modify it under
87 the same terms as the Perl 5 programming language system itself.
88  
89 =cut
« lib/Template/Mustache/Token/Partial.pm ↑ Summary lib/Template/Mustache/Token/Verbatim.pm »