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.22';
2             use strict;
3 24     24   138 use warnings;
  24         46  
  24         571  
4 24     24   107 require Template::Liquid::Error;
  24         41  
  24         724  
5             require Template::Liquid::Utility;
6             use base 'Template::Liquid::Tag::If';
7 24     24   103  
  24         44  
  24         5046  
8 24     24   101 my ($s) = @_;
9             return $s->{'blocks'}->[0]->render()
10             if !(grep { $_->is_true ? 1 : 0 }
11 42     42 0 65 @{$s->{'blocks'}->[0]->{'conditions'}});
12             for my $index (1 .. $#{$s->{'blocks'}}) {
13 41 100       99 my $block = $s->{'blocks'}->[$index];
14 42 100       49 return $block->render() if grep { $_ || 0 } @{$block->{'conditions'}};
  42         89  
15 15         31 }
  15         64  
16 4         6 }
17 4 100       8 1;
  4 100       10  
  4         8  
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