blib/lib/Template/Liquid/Tag/Unless.pm

filter: Statementstmt 100% 24 / 24 Branchbran 100% 8 / 8 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 5 / 5 Podpod 0.0% 0 / 1 totaltotal 97.3% 37 / 38 CC 6 SCAR 13.9
CC
6
Cov
100%
render
6.0
BEGIN
1.0
BEGIN
1.0
CRAP 4.0
« blib/lib/Template/Liquid/Block.pm ↑ Summary blib/lib/Template/Liquid/Tag/Capture.pm »
1 package Template::Liquid::Tag::Unless;
2 24 our $VERSION = '1.0.22';
3 24 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 24 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 24 require Template::Liquid::Error;
6 24 require Template::Liquid::Utility;
7 24 ▶use base 'Template::Liquid::Tag::If';
Subroutine BEGIN: called CC=1 SCAR=0.0
8 24 ▶sub import { Template::Liquid::register_tag('unless') }
Subroutine import: called CC=1 SCAR=0.0
9  
10 sub render {
11 42 ▶ my ($s) = @_;
Subroutine render: called CC=6 SCAR=17.9
Pod undocumented
12 return $s->{'blocks'}->[0]->render()
13 41 ▶ if !(grep { $_->is_true ? 1 : 0 }
Branch: 1 branch
BranchTrueFalseTotal
$_->is_true ? : 15 26 41
14 42 ▶ @{$s->{'blocks'}->[0]->{'conditions'}});
Branch: 1 branch
BranchTrueFalseTotal
unless grep {$_->is_true ? 1 : 0;} @{$$s{"blocks"}[0]{"conditions"};} 27 15 42
15 15 for my $index (1 .. $#{$s->{'blocks'}}) {
16 4 my $block = $s->{'blocks'}->[$index];
17 4 ▶ return $block->render() if grep { $_ || 0 } @{$block->{'conditions'}};
Branch: 2 branches
BranchTrueFalseTotal
if grep {$_ or 0;} @{$$block{"conditions"};} 1 3 4
$_ or 0 3 1 4
18 }
19 }
20 24 1;
21  
22 =pod
23  
24 =encoding UTF-8
25  
26 =begin stopwords
27  
28 Lütke jadedPixel
29  
30 =end stopwords
31  
32 =head1 NAME
33  
34 Template::Liquid::Tag::Unless - Unless: The Opposite of If
35  
36 =head1 Description
37  
38 Unless is the opposite of L<if|Template::Liquid::Tag::If>. The block is
39 rendered I<unless> the condition is true.
40  
41 =head1 Synopsis
42  
43 {% unless value == 5 %}
44 Doesn't equal five!
45 {% else %}
46 Aww... it does equal five.
47 {% endunless %}
48  
49 =head1 Bugs
50  
51 Since L<unless|Template::Liquid::Tag::Unless> is simply a subclass, see the
52 list of bugs for L<if|Template::Liquid::Tag::If>. They basically apply here
53 too.
54  
55 =head1 See Also
56  
57 See L<Template::Liquid::Condition|Template::Liquid::Condition> for a list of
58 supported inequalities.
59  
60 =head1 Author
61  
62 Sanko Robinson <sanko@cpan.org> - http://sankorobinson.com/
63  
64 The original Liquid template system was developed by jadedPixel
65 (http://jadedpixel.com/) and Tobias Lütke (http://blog.leetsoft.com/).
66  
67 =head1 License and Legal
68  
69 Copyright (C) 2009-2022 by Sanko Robinson E<lt>sanko@cpan.orgE<gt>
70  
71 This program is free software; you can redistribute it and/or modify it under
72 the terms of The Artistic License 2.0. See the F<LICENSE> file included with
73 this distribution or http://www.perlfoundation.org/artistic_license_2_0. For
74 clarification, see http://www.perlfoundation.org/artistic_2_0_notes.
75  
76 When separated from the distribution, all original POD documentation is covered
77 by the Creative Commons Attribution-Share Alike 3.0 License. See
78 http://creativecommons.org/licenses/by-sa/3.0/us/legalcode. For clarification,
79 see http://creativecommons.org/licenses/by-sa/3.0/us/.
80  
81 =cut
« blib/lib/Template/Liquid/Block.pm ↑ Summary blib/lib/Template/Liquid/Tag/Capture.pm »