File Coverage

blib/lib/Template/Liquid/Tag/Break.pm
Criterion Covered Total %
statement 19 21 90.4
branch 3 6 50.0
condition n/a
subroutine 6 7 85.7
pod 0 2 0.0
total 28 36 77.7


line stmt bran cond sub pod time code
1             our $VERSION = '1.0.22';
2             use strict;
3 24     24   148 use warnings;
  24         42  
  24         620  
4 24     24   103 require Template::Liquid::Error;
  24         87  
  24         840  
5             require Template::Liquid::Utility;
6             BEGIN { use base 'Template::Liquid::Tag'; }
7 24     24   112  
  24     0   39  
  24         6385  
  0         0  
8 24     24   73 my ($class, $args) = @_;
9             raise Template::Liquid::Error {type => 'Context',
10             template => $args->{template},
11 14     14 0 29 message => 'Missing template argument',
12             fatal => 1
13             }
14             if !defined $args->{'template'};
15             raise Template::Liquid::Error {type => 'Context',
16             template => $args->{template},
17 14 50       29 message => 'Missing parent argument',
18             fatal => 1
19             }
20             if !defined $args->{'parent'};
21             if ($args->{'attrs'}) {
22             raise Template::Liquid::Error {
23 14 50       23 template => $args->{template},
24 14 50       29 type => 'Syntax',
25             message => 'Bad argument list in ' . $args->{'markup'},
26             fatal => 1
27             };
28 0         0 }
29             my $s = bless {name => '#-' . $1,
30             nodelist => [],
31             tag_name => $args->{'tag_name'},
32             template => $args->{'template'},
33             parent => $args->{'parent'},
34             markup => $args->{'markup'}
35             }, $class;
36             return $s;
37 14         76 }
38              
39 14         139 my $s = shift;
40             $s->{template}->{break} = 1;
41             return '';
42             }
43 4     4 0 6 1;
44 4         7  
45 4         8 =pod
46              
47             =encoding UTF-8
48              
49             =begin stopwords
50              
51             Lütke jadedPixel
52              
53             =end stopwords
54              
55             =head1 NAME
56              
57             Template::Liquid::Tag::Break - For-block killing construct
58              
59             =head1 Synopsis
60              
61             {% for item in collection %}
62             {% if item.condition %}
63             {% break %}
64             {% endif %}
65             {% endfor %}
66              
67             =head1 Description
68              
69             You can use the C<{% break %}> tag to break out of the enclosing
70             L<for|Template::Liquid::Tag::For> block. Every for block is implicitly ended
71             with a break.
72              
73             =head1 See Also
74              
75             Liquid for Designers: http://wiki.github.com/tobi/liquid/liquid-for-designers
76              
77             L<Template::Liquid|Template::Liquid/"Create your own filters">'s docs on custom
78             filter creation
79              
80             =head1 Author
81              
82             Sanko Robinson <sanko@cpan.org> - http://sankorobinson.com/
83              
84             The original Liquid template system was developed by jadedPixel
85             (http://jadedpixel.com/) and Tobias Lütke (http://blog.leetsoft.com/).
86              
87             =head1 License and Legal
88              
89             Copyright (C) 2009-2022 by Sanko Robinson E<lt>sanko@cpan.orgE<gt>
90              
91             This program is free software; you can redistribute it and/or modify it under
92             the terms of The Artistic License 2.0. See the F<LICENSE> file included with
93             this distribution or http://www.perlfoundation.org/artistic_license_2_0. For
94             clarification, see http://www.perlfoundation.org/artistic_2_0_notes.
95              
96             When separated from the distribution, all original POD documentation is covered
97             by the Creative Commons Attribution-Share Alike 3.0 License. See
98             http://creativecommons.org/licenses/by-sa/3.0/us/legalcode. For clarification,
99             see http://creativecommons.org/licenses/by-sa/3.0/us/.
100              
101             =cut