line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
our $VERSION = '1.0.21'; |
2
|
|
|
|
|
|
|
require Template::Liquid::Error; |
3
|
|
|
|
|
|
|
use base 'Template::Liquid::Document'; |
4
|
24
|
|
|
24
|
|
127
|
use strict; |
|
24
|
|
|
|
|
45
|
|
|
24
|
|
|
|
|
1335
|
|
5
|
24
|
|
|
24
|
|
130
|
use warnings; |
|
24
|
|
|
|
|
42
|
|
|
24
|
|
|
|
|
356
|
|
6
|
24
|
|
|
24
|
|
89
|
|
|
24
|
|
|
|
|
43
|
|
|
24
|
|
|
|
|
9654
|
|
7
|
|
|
|
|
|
|
my ($class, $args) = @_; |
8
|
|
|
|
|
|
|
raise Template::Liquid::Error {type => 'Context', |
9
|
264
|
|
|
264
|
0
|
480
|
template => $args->{template}, |
10
|
|
|
|
|
|
|
message => 'Missing template argument', |
11
|
|
|
|
|
|
|
fatal => 1 |
12
|
|
|
|
|
|
|
} |
13
|
|
|
|
|
|
|
if !defined $args->{'template'}; |
14
|
|
|
|
|
|
|
raise Template::Liquid::Error {type => 'Context', |
15
|
264
|
50
|
|
|
|
500
|
template => $args->{template}, |
16
|
|
|
|
|
|
|
message => 'Missing parent argument', |
17
|
|
|
|
|
|
|
fatal => 1 |
18
|
|
|
|
|
|
|
} |
19
|
|
|
|
|
|
|
if !defined $args->{'parent'}; |
20
|
|
|
|
|
|
|
raise Template::Liquid::Error { |
21
|
264
|
50
|
|
|
|
454
|
template => $args->{template}, |
22
|
|
|
|
|
|
|
type => 'Syntax', |
23
|
|
|
|
|
|
|
message => 'else tags are non-conditional: ' . $args->{'markup'}, |
24
|
|
|
|
|
|
|
fatal => 1 |
25
|
|
|
|
|
|
|
} |
26
|
|
|
|
|
|
|
if $args->{'tag_name'} eq 'else' && $args->{'attrs'}; |
27
|
|
|
|
|
|
|
my $s = bless {tag_name => 'b-' . $args->{'tag_name'}, |
28
|
264
|
50
|
66
|
|
|
581
|
conditions => undef, |
29
|
|
|
|
|
|
|
nodelist => [], |
30
|
|
|
|
|
|
|
template => $args->{'template'}, |
31
|
|
|
|
|
|
|
parent => $args->{'parent'}, |
32
|
|
|
|
|
|
|
}, $class; |
33
|
264
|
|
|
|
|
966
|
$s->{'conditions'} = ( |
34
|
|
|
|
|
|
|
$args->{'tag_name'} eq 'else' ? [1] : sub { # Oh, what a mess... |
35
|
|
|
|
|
|
|
my @conditions |
36
|
|
|
|
|
|
|
= split |
37
|
|
|
|
|
|
|
m/(?:\s+\b(and|or)\b\s+)(?![^"]*"(?:[^"]*"[^"]*")*[^"]*$)/o, |
38
|
|
|
|
|
|
|
$args->{parent}->{tag_name} eq 'for' |
39
|
|
|
|
|
|
|
? 1 |
40
|
|
|
|
|
|
|
: (defined $args->{'attrs'} ? $args->{'attrs'} : ''); |
41
|
|
|
|
|
|
|
my @equality; |
42
|
242
|
50
|
|
242
|
|
1124
|
while (my $x = shift @conditions) { |
|
|
100
|
|
|
|
|
|
43
|
242
|
|
|
|
|
342
|
push @equality, |
44
|
242
|
|
|
|
|
559
|
( |
45
|
|
|
|
|
|
|
$x |
46
|
|
|
|
|
|
|
=~ m/(?:\b(and|or)\b)(?![^"]*"(?:[^"]*"[^"]*")*[^"]*$)/o |
47
|
|
|
|
|
|
|
? bless({template => $args->{'template'}, |
48
|
|
|
|
|
|
|
parent => $s, |
49
|
|
|
|
|
|
|
condition => $x, |
50
|
|
|
|
|
|
|
lvalue => pop @equality, |
51
|
|
|
|
|
|
|
rvalue => |
52
|
|
|
|
|
|
|
Template::Liquid::Condition->new( |
53
|
|
|
|
|
|
|
{template => $args->{'template'}, |
54
|
|
|
|
|
|
|
parent => $s, |
55
|
|
|
|
|
|
|
attrs => shift @conditions |
56
|
|
|
|
|
|
|
} |
57
|
|
|
|
|
|
|
) |
58
|
|
|
|
|
|
|
}, |
59
|
|
|
|
|
|
|
'Template::Liquid::Condition' |
60
|
|
|
|
|
|
|
) |
61
|
|
|
|
|
|
|
: Template::Liquid::Condition->new( |
62
|
|
|
|
|
|
|
{attrs => $x, |
63
|
|
|
|
|
|
|
template => $args->{'template'}, |
64
|
|
|
|
|
|
|
parent => $s, |
65
|
265
|
100
|
|
|
|
1408
|
} |
66
|
|
|
|
|
|
|
) |
67
|
|
|
|
|
|
|
); |
68
|
|
|
|
|
|
|
} |
69
|
|
|
|
|
|
|
\@equality; |
70
|
|
|
|
|
|
|
} |
71
|
242
|
|
|
|
|
532
|
->() |
72
|
|
|
|
|
|
|
); |
73
|
264
|
100
|
|
|
|
1233
|
return $s; |
74
|
|
|
|
|
|
|
} |
75
|
264
|
|
|
|
|
1288
|
1; |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
=pod |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
=encoding UTF-8 |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
=begin stopwords |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
sorta whitespace Lütke jadedPixel |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
=end stopwords |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
=head1 NAME |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
Template::Liquid::Block - Simple Node Type |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
=head1 Description |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
There's not really a lot to say about basic blocks. The real action is in the |
94
|
|
|
|
|
|
|
classes which make use of them or subclass it. See |
95
|
|
|
|
|
|
|
L<if|Template::Liquid::Tag::If>, L<unless|Template::Liquid::Tag::Unless>, or |
96
|
|
|
|
|
|
|
L<case|Template::Liquid::Tag::Case>. |
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
=head1 Bugs |
99
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
Liquid's (and by extension L<Template::Liquid|Template::Liquid>'s) treatment of |
101
|
|
|
|
|
|
|
compound inequalities is broken. For example... |
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
{% if 'This and that' contains 'that' and 1 == 3 %} |
104
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
...would be parsed as if it were... |
106
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
if ( "'This" && ( "that'" =~ m[and] ) ) { ... |
108
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
...but it should look like... |
110
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
if ( ( 'This and that' =~ m[that]) && ( 1 == 3 ) ) { ... |
112
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
It's just... not pretty but I'll work on it. |
114
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
=head1 See Also |
116
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
See L<Template::Liquid::Condition|Template::Liquid::Condition> for a list of |
118
|
|
|
|
|
|
|
supported inequalities. |
119
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
=head1 Author |
121
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
Sanko Robinson <sanko@cpan.org> - http://sankorobinson.com/ |
123
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
The original Liquid template system was developed by jadedPixel |
125
|
|
|
|
|
|
|
(http://jadedpixel.com/) and Tobias Lütke (http://blog.leetsoft.com/). |
126
|
|
|
|
|
|
|
|
127
|
|
|
|
|
|
|
=head1 License and Legal |
128
|
|
|
|
|
|
|
|
129
|
|
|
|
|
|
|
Copyright (C) 2009-2022 by Sanko Robinson E<lt>sanko@cpan.orgE<gt> |
130
|
|
|
|
|
|
|
|
131
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify it under |
132
|
|
|
|
|
|
|
the terms of The Artistic License 2.0. See the F<LICENSE> file included with |
133
|
|
|
|
|
|
|
this distribution or http://www.perlfoundation.org/artistic_license_2_0. For |
134
|
|
|
|
|
|
|
clarification, see http://www.perlfoundation.org/artistic_2_0_notes. |
135
|
|
|
|
|
|
|
|
136
|
|
|
|
|
|
|
When separated from the distribution, all original POD documentation is covered |
137
|
|
|
|
|
|
|
by the Creative Commons Attribution-Share Alike 3.0 License. See |
138
|
|
|
|
|
|
|
http://creativecommons.org/licenses/by-sa/3.0/us/legalcode. For clarification, |
139
|
|
|
|
|
|
|
see http://creativecommons.org/licenses/by-sa/3.0/us/. |
140
|
|
|
|
|
|
|
|
141
|
|
|
|
|
|
|
=cut |