File Coverage

blib/lib/Template/Liquid/Tag/Raw.pm
Criterion Covered Total %
statement 27 28 96.4
branch 7 12 58.3
condition 4 6 66.6
subroutine 7 7 100.0
pod 0 2 0.0
total 45 55 81.8


line stmt bran cond sub pod time code
1             our $VERSION = '1.0.21';
2             use strict;
3 24     24   138 use warnings;
  24         41  
  24         567  
4 24     24   102 require Template::Liquid::Error;
  24         46  
  24         636  
5             use base 'Template::Liquid::Tag';
6 24     24   100  
  24         42  
  24         8188  
7 24     24   88 my ($class, $args) = @_;
8             raise Template::Liquid::Error {type => 'Context',
9             template => $args->{template},
10 3     3 0 6 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 3 50       6 message => 'Missing parent argument',
17             fatal => 1
18             }
19             if !defined $args->{'parent'};
20             my $s = bless {name => '?-' . int rand(time),
21             blocks => [],
22 3 50       7 tag_name => $args->{'tag_name'},
23             template => $args->{'template'},
24             parent => $args->{'parent'},
25             markup => $args->{'markup'},
26             end_tag => 'end' . $args->{'tag_name'}
27             }, $class;
28             return $s;
29 3         49 }
30              
31 3         9 my ($s) = @_;
32             my $var = $s->{'variable_name'};
33             my $val = '';
34             return _dump_nodes(@{$s->{'nodelist'}});
35 3     3 0 5 }
36 3         4  
37 3         5 my $ret = '';
38 3         3 for my $node (@_) {
  3         7  
39             my $rendering = ref $node ? $node->{'markup'} : $node;
40             $ret .= defined $rendering ? $rendering : '';
41             $ret .= _dump_nodes(@{$node->{'nodelist'}})
42 3     3   4 if ref $node && $node->{'nodelist'};
43 3         3 $ret .= ref $node &&
44 9 100       18 defined $node->{'markup_2'} ? $node->{'markup_2'} : '';
45 9 50       14 }
46 0         0 return $ret;
47 9 50 66     20 }
48             1;
49 9 50 66     23  
50             =pod
51 3         7  
52             =encoding UTF-8
53              
54             =begin stopwords
55              
56             Lütke jadedPixel
57              
58             =end stopwords
59              
60             =head1 NAME
61              
62             Template::Liquid::Tag::Raw - General Purpose Content Container
63              
64             =head1 Synopsis
65              
66             {% raw %}
67             In Handlebars, {{ this }} will be HTML-escaped, but {{{ that }}} will not.
68             {% endraw %}
69              
70             =head1 Description
71              
72             C<raw> is a simple tag. Child nodes are rendered as they appear in the
73             template. Code inside a C<raw> tag is dumped as-is during rendering. So,
74             this...
75              
76             {% raw %}
77             {% for article in articles %}
78             <div class='post' id='{{ article.id }}'>
79             <p class='title'>{{ article.title | capitalize }}</p>
80             {% comment %}
81             Unless we're viewing a single article, we will truncate
82             article.body at 50 words and insert a 'Read more' link.
83             {% endcomment %}
84             ...
85             </div>
86             {% endfor %}
87             {% endraw %}
88              
89             ...would print...
90              
91             {% for article in articles %}
92             <div class='post' id='{{ article.id }}'>
93             <p class='title'>{{ article.title | capitalize }}</p>
94             {% comment %}
95             Unless we're viewing a single article, we will truncate
96             article.body at 50 words and insert a 'Read more' link.
97             {% endcomment %}
98             ...
99             </div>
100             {% endfor %}
101              
102             =head1 See Also
103              
104             Liquid for Designers: http://wiki.github.com/tobi/liquid/liquid-for-designers
105              
106             =head1 Author
107              
108             Sanko Robinson <sanko@cpan.org> - http://sankorobinson.com/
109              
110             The original Liquid template system was developed by jadedPixel
111             (http://jadedpixel.com/) and Tobias Lütke (http://blog.leetsoft.com/).
112              
113             =head1 License and Legal
114              
115             Copyright (C) 2012-2022 by Sanko Robinson E<lt>sanko@cpan.orgE<gt>
116              
117             This program is free software; you can redistribute it and/or modify it under
118             the terms of The Artistic License 2.0. See the F<LICENSE> file included with
119             this distribution or http://www.perlfoundation.org/artistic_license_2_0. For
120             clarification, see http://www.perlfoundation.org/artistic_2_0_notes.
121              
122             When separated from the distribution, all original POD documentation is covered
123             by the Creative Commons Attribution-Share Alike 3.0 License. See
124             http://creativecommons.org/licenses/by-sa/3.0/us/legalcode. For clarification,
125             see http://creativecommons.org/licenses/by-sa/3.0/us/.
126              
127             =cut