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