line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
our $VERSION = '1.0.22'; |
2
|
|
|
|
|
|
|
use strict; |
3
|
24
|
|
|
24
|
|
137
|
use warnings; |
|
24
|
|
|
|
|
40
|
|
|
24
|
|
|
|
|
574
|
|
4
|
24
|
|
|
24
|
|
105
|
use Template::Liquid::Variable; |
|
24
|
|
|
|
|
35
|
|
|
24
|
|
|
|
|
512
|
|
5
|
24
|
|
|
24
|
|
9482
|
use Template::Liquid::Utility; |
|
24
|
|
|
|
|
54
|
|
|
24
|
|
|
|
|
634
|
|
6
|
24
|
|
|
24
|
|
8506
|
# |
|
24
|
|
|
|
|
69
|
|
|
24
|
|
|
|
|
17911
|
|
7
|
|
|
|
|
|
|
my ($class, $args) = @_; |
8
|
|
|
|
|
|
|
raise Template::Liquid::Error {type => 'Context', |
9
|
359
|
|
|
359
|
0
|
674
|
template => (), |
10
|
|
|
|
|
|
|
message => 'Missing template argument', |
11
|
|
|
|
|
|
|
fatal => 1 |
12
|
|
|
|
|
|
|
} |
13
|
|
|
|
|
|
|
if !defined $args->{'template'}; |
14
|
|
|
|
|
|
|
return |
15
|
359
|
50
|
|
|
|
757
|
bless {template => $args->{'template'}, |
16
|
|
|
|
|
|
|
parent => $args->{'template'} |
17
|
|
|
|
|
|
|
}, $class; |
18
|
359
|
|
|
|
|
1746
|
} |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
my ($class, $args, $tokens); |
21
|
|
|
|
|
|
|
(scalar @_ == 3 ? ($class, $args, $tokens) : ($class, $tokens)) = @_; |
22
|
|
|
|
|
|
|
my $s = ref $class ? $class : $class->new($args); |
23
|
588
|
|
|
588
|
0
|
858
|
my %_tags = $s->{template}->tags; |
24
|
588
|
50
|
|
|
|
1650
|
NODE: while (defined(my $token = shift @{$tokens})) { |
25
|
588
|
50
|
|
|
|
1160
|
if ($token =~ $Template::Liquid::Utility::TagMatch) { |
26
|
588
|
|
|
|
|
1405
|
my ($tag, $attrs) = (split ' ', $1, 2); |
27
|
588
|
|
|
|
|
1211
|
my $package = $_tags{$tag}; |
|
2389
|
|
|
|
|
4809
|
|
28
|
2030
|
100
|
|
|
|
11137
|
my $call = $package ? $package->can('new') : (); |
|
|
100
|
|
|
|
|
|
29
|
625
|
|
|
|
|
1888
|
if (defined $call) { |
30
|
625
|
|
|
|
|
1149
|
my $_tag = $call->($package, |
31
|
625
|
100
|
|
|
|
2883
|
{template => $s->{template}, |
32
|
625
|
100
|
66
|
|
|
2038
|
parent => $s, |
|
|
100
|
33
|
|
|
|
|
|
|
50
|
|
|
|
|
|
33
|
|
|
|
|
|
|
tag_name => $tag, |
34
|
|
|
|
|
|
|
markup => $token, |
35
|
335
|
|
|
|
|
1557
|
attrs => $attrs |
36
|
|
|
|
|
|
|
} |
37
|
|
|
|
|
|
|
); |
38
|
|
|
|
|
|
|
push @{$s->{'nodelist'}}, $_tag; |
39
|
|
|
|
|
|
|
if ($_tag->conditional_tag) { |
40
|
|
|
|
|
|
|
push @{$_tag->{'blocks'}}, |
41
|
335
|
|
|
|
|
852
|
Template::Liquid::Block->new( |
|
335
|
|
|
|
|
615
|
|
42
|
335
|
100
|
|
|
|
923
|
{tag_name => $tag, |
|
|
100
|
|
|
|
|
|
43
|
203
|
|
|
|
|
890
|
attrs => $attrs, |
44
|
|
|
|
|
|
|
template => $_tag->{template}, |
45
|
|
|
|
|
|
|
parent => $_tag |
46
|
|
|
|
|
|
|
} |
47
|
|
|
|
|
|
|
); |
48
|
203
|
|
|
|
|
289
|
$_tag->parse($tokens); |
49
|
|
|
|
|
|
|
{ # finish previous block |
50
|
|
|
|
|
|
|
${$_tag->{'blocks'}[-1]}{'nodelist'} |
51
|
203
|
|
|
|
|
825
|
= $_tag->{'nodelist'}; |
52
|
|
|
|
|
|
|
$_tag->{'nodelist'} = []; |
53
|
203
|
|
|
|
|
253
|
} |
|
203
|
|
|
|
|
420
|
|
54
|
203
|
|
|
|
|
260
|
} |
55
|
203
|
|
|
|
|
417
|
elsif ($_tag->end_tag) { |
56
|
|
|
|
|
|
|
$_tag->parse($tokens); |
57
|
|
|
|
|
|
|
} |
58
|
|
|
|
|
|
|
} |
59
|
26
|
|
|
|
|
156
|
elsif ($s->can('end_tag') && $tag =~ $s->end_tag) { |
60
|
|
|
|
|
|
|
$s->{'markup_2'} = $token; |
61
|
|
|
|
|
|
|
last NODE; |
62
|
|
|
|
|
|
|
} |
63
|
229
|
|
|
|
|
477
|
elsif ($s->conditional_tag && $tag =~ $s->conditional_tag) { |
64
|
229
|
|
|
|
|
508
|
$s->push_block({tag_name => $tag, |
65
|
|
|
|
|
|
|
attrs => $attrs, |
66
|
|
|
|
|
|
|
markup => $token, |
67
|
|
|
|
|
|
|
template => $s->{template}, |
68
|
|
|
|
|
|
|
parent => $s |
69
|
|
|
|
|
|
|
}, |
70
|
|
|
|
|
|
|
$tokens |
71
|
61
|
|
|
|
|
292
|
); |
72
|
|
|
|
|
|
|
} |
73
|
|
|
|
|
|
|
else { |
74
|
|
|
|
|
|
|
raise Template::Liquid::Error { |
75
|
|
|
|
|
|
|
type => 'Syntax', |
76
|
|
|
|
|
|
|
template => $s->{template}, |
77
|
|
|
|
|
|
|
message => 'Unknown tag: ' . $token |
78
|
|
|
|
|
|
|
}; |
79
|
|
|
|
|
|
|
} |
80
|
0
|
|
|
|
|
0
|
} |
81
|
|
|
|
|
|
|
elsif ($token =~ $Template::Liquid::Utility::VarMatch) { |
82
|
|
|
|
|
|
|
my ($variable, $filters) = split qr[\s*\|\s*]o, $1, 2; |
83
|
|
|
|
|
|
|
my @filters; |
84
|
|
|
|
|
|
|
for my $filter (split $Template::Liquid::Utility::FilterSeparator, |
85
|
293
|
|
|
|
|
1684
|
$filters || '') { |
86
|
293
|
|
|
|
|
606
|
my ($filter, $args) |
87
|
293
|
|
100
|
|
|
1146
|
= split |
88
|
|
|
|
|
|
|
$Template::Liquid::Utility::FilterArgumentSeparator, |
89
|
164
|
|
|
|
|
520
|
$filter, 2; |
90
|
|
|
|
|
|
|
$filter =~ s[\s*$][]o; # XXX - the splitter should clean... |
91
|
|
|
|
|
|
|
$filter =~ s[^\s*][]o; # XXX - ...this up for us. |
92
|
|
|
|
|
|
|
my @args |
93
|
164
|
|
|
|
|
613
|
= !defined $args ? () : grep { defined $_ } |
94
|
164
|
|
|
|
|
416
|
$args |
95
|
|
|
|
|
|
|
=~ m[$Template::Liquid::Utility::VariableFilterArgumentParser]g; |
96
|
164
|
100
|
|
|
|
701
|
push @filters, [$filter, \@args]; |
|
342
|
|
|
|
|
611
|
|
97
|
|
|
|
|
|
|
} |
98
|
|
|
|
|
|
|
push @{$s->{'nodelist'}}, |
99
|
164
|
|
|
|
|
468
|
Template::Liquid::Variable->new( |
100
|
|
|
|
|
|
|
{template => $s->{template}, |
101
|
293
|
|
|
|
|
1651
|
parent => $s, |
102
|
|
|
|
|
|
|
markup => $token, |
103
|
|
|
|
|
|
|
variable => $variable, |
104
|
293
|
|
|
|
|
424
|
filters => \@filters |
105
|
|
|
|
|
|
|
} |
106
|
|
|
|
|
|
|
); |
107
|
|
|
|
|
|
|
} |
108
|
|
|
|
|
|
|
else { |
109
|
|
|
|
|
|
|
push @{$s->{'nodelist'}}, $token; |
110
|
|
|
|
|
|
|
} |
111
|
|
|
|
|
|
|
{ # Move the cursor |
112
|
1112
|
|
|
|
|
1458
|
my $x = ($token =~ m[(\n)]g); |
|
1112
|
|
|
|
|
2312
|
|
113
|
|
|
|
|
|
|
my $nl = $token =~ tr/\n//; |
114
|
|
|
|
|
|
|
$s->{template}{line} += $nl; |
115
|
1801
|
|
|
|
|
2383
|
$s->{template}{column} = $nl |
|
1801
|
|
|
|
|
3507
|
|
116
|
1801
|
|
|
|
|
2662
|
? rindex $token, "\n" |
117
|
1801
|
|
|
|
|
2544
|
: $s->{template}{column} + length $token; |
118
|
|
|
|
|
|
|
} |
119
|
|
|
|
|
|
|
} |
120
|
1801
|
100
|
|
|
|
4340
|
return $s; |
121
|
|
|
|
|
|
|
} |
122
|
|
|
|
|
|
|
|
123
|
588
|
|
|
|
|
1938
|
my ($s) = @_; |
124
|
|
|
|
|
|
|
my $return = ''; |
125
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
# print STDERR "DEBUG RENDERING NODE\n"; |
127
|
468
|
|
|
468
|
0
|
742
|
for my $node (@{$s->{'nodelist'}}) { |
128
|
468
|
|
|
|
|
658
|
my $rendering = ref $node ? $node->render() : $node; |
129
|
|
|
|
|
|
|
$return .= defined $rendering ? $rendering : ''; |
130
|
|
|
|
|
|
|
} |
131
|
468
|
|
|
|
|
549
|
return $return; |
|
468
|
|
|
|
|
924
|
|
132
|
1301
|
100
|
|
|
|
2717
|
} |
133
|
1301
|
100
|
|
|
|
3169
|
1; |
134
|
|
|
|
|
|
|
|
135
|
468
|
|
|
|
|
1083
|
=pod |
136
|
|
|
|
|
|
|
|
137
|
0
|
|
0
|
0
|
0
|
|
=encoding UTF-8 |
138
|
|
|
|
|
|
|
|
139
|
|
|
|
|
|
|
=begin stopwords |
140
|
|
|
|
|
|
|
|
141
|
|
|
|
|
|
|
Lütke jadedPixel |
142
|
|
|
|
|
|
|
|
143
|
|
|
|
|
|
|
=end stopwords |
144
|
|
|
|
|
|
|
|
145
|
|
|
|
|
|
|
=head1 NAME |
146
|
|
|
|
|
|
|
|
147
|
|
|
|
|
|
|
Template::Liquid::Document - Generic Top-level Object |
148
|
|
|
|
|
|
|
|
149
|
|
|
|
|
|
|
=head1 Description |
150
|
|
|
|
|
|
|
|
151
|
|
|
|
|
|
|
This shouldn't be used. ...unless you're really interested in how things work. |
152
|
|
|
|
|
|
|
This is the grandfather class; everything is a child or subclass of this |
153
|
|
|
|
|
|
|
object. |
154
|
|
|
|
|
|
|
|
155
|
|
|
|
|
|
|
=head1 Author |
156
|
|
|
|
|
|
|
|
157
|
|
|
|
|
|
|
Sanko Robinson <sanko@cpan.org> - http://sankorobinson.com/ |
158
|
|
|
|
|
|
|
|
159
|
|
|
|
|
|
|
The original Liquid template system was developed by jadedPixel |
160
|
|
|
|
|
|
|
(http://jadedpixel.com/) and Tobias Lütke (http://blog.leetsoft.com/). |
161
|
|
|
|
|
|
|
|
162
|
|
|
|
|
|
|
=head1 License and Legal |
163
|
|
|
|
|
|
|
|
164
|
|
|
|
|
|
|
Copyright (C) 2009-2022 by Sanko Robinson E<lt>sanko@cpan.orgE<gt> |
165
|
|
|
|
|
|
|
|
166
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify it under |
167
|
|
|
|
|
|
|
the terms of The Artistic License 2.0. See the F<LICENSE> file included with |
168
|
|
|
|
|
|
|
this distribution or http://www.perlfoundation.org/artistic_license_2_0. For |
169
|
|
|
|
|
|
|
clarification, see http://www.perlfoundation.org/artistic_2_0_notes. |
170
|
|
|
|
|
|
|
|
171
|
|
|
|
|
|
|
When separated from the distribution, all original POD documentation is covered |
172
|
|
|
|
|
|
|
by the Creative Commons Attribution-Share Alike 3.0 License. See |
173
|
|
|
|
|
|
|
http://creativecommons.org/licenses/by-sa/3.0/us/legalcode. For clarification, |
174
|
|
|
|
|
|
|
see http://creativecommons.org/licenses/by-sa/3.0/us/. |
175
|
|
|
|
|
|
|
|
176
|
|
|
|
|
|
|
=cut |