| 1 | package Template::Liquid::Tag::Comment; | ||||||||||
| 2 | 25 | our $VERSION = '1.0.23'; | |||||||||
| 3 | 25 | ▶ | use strict; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 4 | 25 | ▶ | use warnings; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 5 | 25 | require Template::Liquid::Error; | |||||||||
| 6 | 25 | ▶ | BEGIN { use base 'Template::Liquid::Tag'; } | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: not called CC=1 SCAR=0.0
| |||||||||||
| 7 | 25 | ▶ | sub import { Template::Liquid::register_tag('comment') } | ||||||||
|
Subroutine
import: called CC=1 SCAR=0.0
| |||||||||||
| 8 | |||||||||||
| 9 | 10 | ▶ | sub new { | ||||||||
|
Subroutine
new: called CC=4 SCAR=15.0
Pod
undocumented
| |||||||||||
| 10 | 10 | 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 | ▶ | if !defined $args->{'template'}; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 17 | raise Template::Liquid::Error {type => 'Context', | ||||||||||
| 18 | template => $args->{template}, | ||||||||||
| 19 | message => 'Missing parent argument', | ||||||||||
| 20 | fatal => 1 | ||||||||||
| 21 | } | ||||||||||
| 22 | 10 | ▶ | if !defined $args->{'parent'}; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 23 | 10 | ▶ | if ($args->{'attrs'}) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 24 | raise Template::Liquid::Error { | ||||||||||
| 25 | type => 'Syntax', | ||||||||||
| 26 | template => $args->{template}, | ||||||||||
| 27 | 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 | markup => $args->{'markup'} | |||||||||
| 38 | }, $class; | ||||||||||
| 39 | 10 | return $s; | |||||||||
| 40 | } | ||||||||||
| 41 | 8 | ▶ | sub render { } | ||||||||
|
Subroutine
render: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||
| 42 | 25 | 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 | ||||||||||