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