File Coverage

blib/lib/Template/Liquid/Tag/Comment.pm
Criterion Covered Total %
statement 16 18 88.8
branch 3 6 50.0
condition n/a
subroutine 6 7 85.7
pod 0 2 0.0
total 25 33 75.7


line stmt bran cond sub pod time code
1             our $VERSION = '1.0.22';
2             use strict;
3 24     24   136 use warnings;
  24         46  
  24         616  
4 24     24   122 require Template::Liquid::Error;
  24         55  
  24         845  
5             BEGIN { use base 'Template::Liquid::Tag'; }
6 24     24   123  
  24     0   67  
  24         6190  
  0         0  
7 24     24   70 my ($class, $args) = @_;
8             raise Template::Liquid::Error {type => 'Context',
9             template => $args->{template},
10 10     10 0 20 message => 'Missing template argument',
11             fatal => 1
12             }
13             if !defined $args->{'template'};
14             raise Template::Liquid::Error {type => 'Context',
15             template => $args->{template},
16 10 50       27 message => 'Missing parent argument',
17             fatal => 1
18             }
19             if !defined $args->{'parent'};
20             if ($args->{'attrs'}) {
21             raise Template::Liquid::Error {
22 10 50       24 type => 'Syntax',
23 10 50       24 template => $args->{template},
24             message => 'Bad argument list in ' . $args->{'markup'},
25             fatal => 1
26             };
27 0         0 }
28             my $s = bless {name => '#-' . $1,
29             nodelist => [],
30             tag_name => $args->{'tag_name'},
31             end_tag => 'end' . $args->{'tag_name'},
32             template => $args->{'template'},
33             parent => $args->{'parent'},
34             markup => $args->{'markup'}
35             }, $class;
36             return $s;
37 10         82 }
38             1;
39 10         109  
40             =pod
41       8 0    
42             =encoding UTF-8
43              
44             =begin stopwords
45              
46             Lütke jadedPixel
47              
48             =end stopwords
49              
50             =head1 NAME
51              
52             Template::Liquid::Tag::Comment - General Purpose Content Eater
53              
54             =head1 Synopsis
55              
56             I love you{% comment %} and your sister {% endcomment %}.
57              
58             =head1 Description
59              
60             C<comment> is the simplest tag. Child nodes are not rendered so it effectively
61             swallows content.
62              
63             {% for article in articles %}
64             <div class='post' id='{{ article.id }}'>
65             <p class='title'>{{ article.title | capitalize }}</p>
66             {% comment %}
67             Unless we're viewing a single article, we will truncate
68             article.body at 50 words and insert a 'Read more' link.
69             {% endcomment %}
70             ...
71             </div>
72             {% endfor %}
73              
74             Code inside a C<comment> tag is not executed during rendering. So, this...
75              
76             {% assign str = 'Initial value' %}
77             {% comment %}
78             {% assign str = 'Different value' %}
79             {% endcomment %}
80             {{ str }}
81              
82             ...would print C<Initial value>.
83              
84             =head1 See Also
85              
86             Liquid for Designers: http://wiki.github.com/tobi/liquid/liquid-for-designers
87              
88             L<Template::Liquid|Template::Liquid/"Create your own filters">'s docs on custom
89             filter creation
90              
91             =head1 Author
92              
93             Sanko Robinson <sanko@cpan.org> - http://sankorobinson.com/
94              
95             The original Liquid template system was developed by jadedPixel
96             (http://jadedpixel.com/) and Tobias Lütke (http://blog.leetsoft.com/).
97              
98             =head1 License and Legal
99              
100             Copyright (C) 2009-2022 by Sanko Robinson E<lt>sanko@cpan.orgE<gt>
101              
102             This program is free software; you can redistribute it and/or modify it under
103             the terms of The Artistic License 2.0. See the F<LICENSE> file included with
104             this distribution or http://www.perlfoundation.org/artistic_license_2_0. For
105             clarification, see http://www.perlfoundation.org/artistic_2_0_notes.
106              
107             When separated from the distribution, all original POD documentation is covered
108             by the Creative Commons Attribution-Share Alike 3.0 License. See
109             http://creativecommons.org/licenses/by-sa/3.0/us/legalcode. For clarification,
110             see http://creativecommons.org/licenses/by-sa/3.0/us/.
111              
112             =cut