line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
our $VERSION = '1.0.21'; |
2
|
|
|
|
|
|
|
use strict; |
3
|
24
|
|
|
24
|
|
125
|
use warnings; |
|
24
|
|
|
|
|
41
|
|
|
24
|
|
|
|
|
545
|
|
4
|
24
|
|
|
24
|
|
95
|
use Template::Liquid::Variable; |
|
24
|
|
|
|
|
39
|
|
|
24
|
|
|
|
|
461
|
|
5
|
24
|
|
|
24
|
|
9049
|
use Template::Liquid::Utility; |
|
24
|
|
|
|
|
54
|
|
|
24
|
|
|
|
|
635
|
|
6
|
24
|
|
|
24
|
|
8053
|
# |
|
24
|
|
|
|
|
68
|
|
|
24
|
|
|
|
|
17381
|
|
7
|
|
|
|
|
|
|
my ($class, $args) = @_; |
8
|
|
|
|
|
|
|
raise Template::Liquid::Error {type => 'Context', |
9
|
359
|
|
|
359
|
0
|
685
|
template => (), |
10
|
|
|
|
|
|
|
message => 'Missing template argument', |
11
|
|
|
|
|
|
|
fatal => 1 |
12
|
|
|
|
|
|
|
} |
13
|
|
|
|
|
|
|
if !defined $args->{'template'}; |
14
|
|
|
|
|
|
|
return |
15
|
359
|
50
|
|
|
|
747
|
bless {template => $args->{'template'}, |
16
|
|
|
|
|
|
|
parent => $args->{'template'} |
17
|
|
|
|
|
|
|
}, $class; |
18
|
359
|
|
|
|
|
1628
|
} |
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
|
865
|
my %_tags = $s->{template}->tags; |
24
|
588
|
50
|
|
|
|
1342
|
NODE: while (defined(my $token = shift @{$tokens})) { |
25
|
588
|
50
|
|
|
|
1109
|
if ($token =~ $Template::Liquid::Utility::TagMatch) { |
26
|
588
|
|
|
|
|
1363
|
my ($tag, $attrs) = (split ' ', $1, 2); |
27
|
588
|
|
|
|
|
1199
|
my $package = $_tags{$tag}; |
|
2389
|
|
|
|
|
4792
|
|
28
|
2030
|
100
|
|
|
|
11155
|
my $call = $package ? $package->can('new') : (); |
|
|
100
|
|
|
|
|
|
29
|
625
|
|
|
|
|
1869
|
if (defined $call) { |
30
|
625
|
|
|
|
|
1076
|
my $_tag = $call->($package, |
31
|
625
|
100
|
|
|
|
2191
|
{template => $s->{template}, |
32
|
625
|
100
|
66
|
|
|
2355
|
parent => $s, |
|
|
100
|
33
|
|
|
|
|
|
|
50
|
|
|
|
|
|
33
|
|
|
|
|
|
|
tag_name => $tag, |
34
|
|
|
|
|
|
|
markup => $token, |
35
|
335
|
|
|
|
|
1519
|
attrs => $attrs |
36
|
|
|
|
|
|
|
} |
37
|
|
|
|
|
|
|
); |
38
|
|
|
|
|
|
|
push @{$s->{'nodelist'}}, $_tag; |
39
|
|
|
|
|
|
|
if ($_tag->conditional_tag) { |
40
|
|
|
|
|
|
|
push @{$_tag->{'blocks'}}, |
41
|
335
|
|
|
|
|
708
|
Template::Liquid::Block->new( |
|
335
|
|
|
|
|
599
|
|
42
|
335
|
100
|
|
|
|
886
|
{tag_name => $tag, |
|
|
100
|
|
|
|
|
|
43
|
203
|
|
|
|
|
864
|
attrs => $attrs, |
44
|
|
|
|
|
|
|
template => $_tag->{template}, |
45
|
|
|
|
|
|
|
parent => $_tag |
46
|
|
|
|
|
|
|
} |
47
|
|
|
|
|
|
|
); |
48
|
203
|
|
|
|
|
261
|
$_tag->parse($tokens); |
49
|
|
|
|
|
|
|
{ # finish previous block |
50
|
|
|
|
|
|
|
${$_tag->{'blocks'}[-1]}{'nodelist'} |
51
|
203
|
|
|
|
|
823
|
= $_tag->{'nodelist'}; |
52
|
|
|
|
|
|
|
$_tag->{'nodelist'} = []; |
53
|
203
|
|
|
|
|
241
|
} |
|
203
|
|
|
|
|
435
|
|
54
|
203
|
|
|
|
|
296
|
} |
55
|
203
|
|
|
|
|
436
|
elsif ($_tag->end_tag) { |
56
|
|
|
|
|
|
|
$_tag->parse($tokens); |
57
|
|
|
|
|
|
|
} |
58
|
|
|
|
|
|
|
} |
59
|
26
|
|
|
|
|
140
|
elsif ($s->can('end_tag') && $tag =~ $s->end_tag) { |
60
|
|
|
|
|
|
|
$s->{'markup_2'} = $token; |
61
|
|
|
|
|
|
|
last NODE; |
62
|
|
|
|
|
|
|
} |
63
|
229
|
|
|
|
|
467
|
elsif ($s->conditional_tag && $tag =~ $s->conditional_tag) { |
64
|
229
|
|
|
|
|
481
|
$s->push_block({tag_name => $tag, |
65
|
|
|
|
|
|
|
attrs => $attrs, |
66
|
|
|
|
|
|
|
markup => $token, |
67
|
|
|
|
|
|
|
template => $s->{template}, |
68
|
|
|
|
|
|
|
parent => $s |
69
|
|
|
|
|
|
|
}, |
70
|
|
|
|
|
|
|
$tokens |
71
|
61
|
|
|
|
|
297
|
); |
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
|
|
|
|
|
1691
|
$filters || '') { |
86
|
293
|
|
|
|
|
655
|
my ($filter, $args) |
87
|
293
|
|
100
|
|
|
1112
|
= split |
88
|
|
|
|
|
|
|
$Template::Liquid::Utility::FilterArgumentSeparator, |
89
|
164
|
|
|
|
|
532
|
$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
|
|
|
|
|
592
|
= !defined $args ? () : grep { defined $_ } |
94
|
164
|
|
|
|
|
373
|
$args |
95
|
|
|
|
|
|
|
=~ m[$Template::Liquid::Utility::VariableFilterArgumentParser]g; |
96
|
164
|
100
|
|
|
|
745
|
push @filters, [$filter, \@args]; |
|
342
|
|
|
|
|
660
|
|
97
|
|
|
|
|
|
|
} |
98
|
|
|
|
|
|
|
push @{$s->{'nodelist'}}, |
99
|
164
|
|
|
|
|
481
|
Template::Liquid::Variable->new( |
100
|
|
|
|
|
|
|
{template => $s->{template}, |
101
|
293
|
|
|
|
|
1550
|
parent => $s, |
102
|
|
|
|
|
|
|
markup => $token, |
103
|
|
|
|
|
|
|
variable => $variable, |
104
|
293
|
|
|
|
|
410
|
filters => \@filters |
105
|
|
|
|
|
|
|
} |
106
|
|
|
|
|
|
|
); |
107
|
|
|
|
|
|
|
} |
108
|
|
|
|
|
|
|
else { |
109
|
|
|
|
|
|
|
push @{$s->{'nodelist'}}, $token; |
110
|
|
|
|
|
|
|
} |
111
|
|
|
|
|
|
|
{ # Move the cursor |
112
|
1112
|
|
|
|
|
1457
|
my $x = ($token =~ m[(\n)]g); |
|
1112
|
|
|
|
|
2283
|
|
113
|
|
|
|
|
|
|
my $nl = $token =~ tr/\n//; |
114
|
|
|
|
|
|
|
$s->{template}{line} += $nl; |
115
|
1801
|
|
|
|
|
2345
|
$s->{template}{column} = $nl |
|
1801
|
|
|
|
|
3555
|
|
116
|
1801
|
|
|
|
|
2645
|
? rindex $token, "\n" |
117
|
1801
|
|
|
|
|
2595
|
: $s->{template}{column} + length $token; |
118
|
|
|
|
|
|
|
} |
119
|
|
|
|
|
|
|
} |
120
|
1801
|
100
|
|
|
|
4077
|
return $s; |
121
|
|
|
|
|
|
|
} |
122
|
|
|
|
|
|
|
|
123
|
588
|
|
|
|
|
1832
|
my ($s) = @_; |
124
|
|
|
|
|
|
|
my $return = ''; |
125
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
# print STDERR "DEBUG RENDERING NODE\n"; |
127
|
468
|
|
|
468
|
0
|
715
|
for my $node (@{$s->{'nodelist'}}) { |
128
|
468
|
|
|
|
|
677
|
my $rendering = ref $node ? $node->render() : $node; |
129
|
|
|
|
|
|
|
$return .= defined $rendering ? $rendering : ''; |
130
|
|
|
|
|
|
|
} |
131
|
468
|
|
|
|
|
619
|
return $return; |
|
468
|
|
|
|
|
864
|
|
132
|
1301
|
100
|
|
|
|
2627
|
} |
133
|
1301
|
100
|
|
|
|
3195
|
1; |
134
|
|
|
|
|
|
|
|
135
|
468
|
|
|
|
|
1049
|
=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 |