File Coverage

blib/lib/Template/Liquid/Tag/Unless.pm
Criterion Covered Total %
statement 20 20 100.0
branch 8 8 100.0
condition n/a
subroutine 5 5 100.0
pod 0 1 0.0
total 33 34 97.0


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