python-liquid 2.0.0__py3-none-any.whl → 2.0.2__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- liquid/__init__.py +1 -1
- liquid/builtin/expressions/loop.py +2 -5
- liquid/builtin/loaders/mixins.py +1 -2
- liquid/extra/tags/macro_tag.py +2 -0
- liquid/messages.py +1 -1
- liquid/static_analysis.py +16 -10
- {python_liquid-2.0.0.dist-info → python_liquid-2.0.2.dist-info}/METADATA +6 -9
- python_liquid-2.0.2.dist-info/RECORD +95 -0
- liquid/golden/__init__.py +0 -173
- liquid/golden/abs_filter.py +0 -73
- liquid/golden/append_filter.py +0 -43
- liquid/golden/assign_tag.py +0 -45
- liquid/golden/at_least_filter.py +0 -78
- liquid/golden/at_most_filter.py +0 -68
- liquid/golden/base64_decode_filter.py +0 -43
- liquid/golden/base64_encode_filter.py +0 -42
- liquid/golden/base64_url_safe_decode_filter.py +0 -43
- liquid/golden/base64_url_safe_encode_filter.py +0 -42
- liquid/golden/capitalize_filter.py +0 -27
- liquid/golden/capture_tag.py +0 -39
- liquid/golden/case.py +0 -28
- liquid/golden/case_tag.py +0 -226
- liquid/golden/ceil_filter.py +0 -63
- liquid/golden/comment_tag.py +0 -119
- liquid/golden/compact_filter.py +0 -54
- liquid/golden/concat_filter.py +0 -63
- liquid/golden/cycle_tag.py +0 -114
- liquid/golden/date_filter.py +0 -63
- liquid/golden/decrement_tag.py +0 -16
- liquid/golden/default_filter.py +0 -112
- liquid/golden/divided_by_filter.py +0 -101
- liquid/golden/doc_tag.py +0 -61
- liquid/golden/downcase_filter.py +0 -27
- liquid/golden/echo_tag.py +0 -116
- liquid/golden/escape_filter.py +0 -27
- liquid/golden/escape_once_filter.py +0 -32
- liquid/golden/find_filter.py +0 -90
- liquid/golden/find_index_filter.py +0 -96
- liquid/golden/first_filter.py +0 -51
- liquid/golden/floor_filter.py +0 -63
- liquid/golden/for_tag.py +0 -642
- liquid/golden/has_filter.py +0 -139
- liquid/golden/identifiers.py +0 -249
- liquid/golden/if_tag.py +0 -531
- liquid/golden/ifchanged_tag.py +0 -46
- liquid/golden/illegal.py +0 -34
- liquid/golden/include_tag.py +0 -196
- liquid/golden/increment_tag.py +0 -48
- liquid/golden/inline_comment_tag.py +0 -127
- liquid/golden/join_filter.py +0 -69
- liquid/golden/last_filter.py +0 -51
- liquid/golden/liquid_tag.py +0 -215
- liquid/golden/lstrip_filter.py +0 -37
- liquid/golden/map_filter.py +0 -50
- liquid/golden/minus_filter.py +0 -58
- liquid/golden/modulo_filter.py +0 -60
- liquid/golden/newline_to_br_filter.py +0 -37
- liquid/golden/not_liquid.py +0 -16
- liquid/golden/output_statement.py +0 -295
- liquid/golden/plus_filter.py +0 -63
- liquid/golden/prepend_filter.py +0 -43
- liquid/golden/range_objects.py +0 -79
- liquid/golden/raw_tag.py +0 -31
- liquid/golden/reject_filter.py +0 -268
- liquid/golden/remove_filter.py +0 -45
- liquid/golden/remove_first_filter.py +0 -46
- liquid/golden/remove_last_filter.py +0 -46
- liquid/golden/render_tag.py +0 -210
- liquid/golden/replace_filter.py +0 -65
- liquid/golden/replace_first_filter.py +0 -59
- liquid/golden/replace_last_filter.py +0 -60
- liquid/golden/reverse_filter.py +0 -42
- liquid/golden/round_filter.py +0 -87
- liquid/golden/rstrip_filter.py +0 -37
- liquid/golden/size_filter.py +0 -42
- liquid/golden/slice_filter.py +0 -119
- liquid/golden/sort_filter.py +0 -86
- liquid/golden/sort_natural_filter.py +0 -105
- liquid/golden/special.py +0 -91
- liquid/golden/split_filter.py +0 -128
- liquid/golden/strip_filter.py +0 -37
- liquid/golden/strip_html_filter.py +0 -74
- liquid/golden/strip_newlines_filter.py +0 -37
- liquid/golden/sum_filter.py +0 -97
- liquid/golden/tablerow_tag.py +0 -399
- liquid/golden/times_filter.py +0 -53
- liquid/golden/truncate_filter.py +0 -61
- liquid/golden/truncatewords_filter.py +0 -94
- liquid/golden/uniq_filter.py +0 -87
- liquid/golden/unless_tag.py +0 -101
- liquid/golden/upcase_filter.py +0 -27
- liquid/golden/url_decode_filter.py +0 -27
- liquid/golden/url_encode_filter.py +0 -27
- liquid/golden/where_filter.py +0 -122
- liquid/golden/whitespace_control.py +0 -281
- python_liquid-2.0.0.dist-info/RECORD +0 -182
- {python_liquid-2.0.0.dist-info → python_liquid-2.0.2.dist-info}/WHEEL +0 -0
- {python_liquid-2.0.0.dist-info → python_liquid-2.0.2.dist-info}/licenses/LICENSE +0 -0
liquid/golden/reject_filter.py
DELETED
|
@@ -1,268 +0,0 @@
|
|
|
1
|
-
"""Test cases for the standard `reject` filter."""
|
|
2
|
-
|
|
3
|
-
from liquid.golden.case import Case
|
|
4
|
-
|
|
5
|
-
cases = [
|
|
6
|
-
Case(
|
|
7
|
-
description="array of strings, default value",
|
|
8
|
-
template=(
|
|
9
|
-
r"{% assign b = a | reject: 'c' %}"
|
|
10
|
-
r"{% for obj in b %}"
|
|
11
|
-
r"{{ obj }}, "
|
|
12
|
-
r"{% endfor %}"
|
|
13
|
-
),
|
|
14
|
-
expect="x, y, ",
|
|
15
|
-
globals={"a": ["x", "y", "cat"]},
|
|
16
|
-
),
|
|
17
|
-
Case(
|
|
18
|
-
description="array containing null, default value",
|
|
19
|
-
template=r"{{ a | reject: 'c' }}",
|
|
20
|
-
expect="",
|
|
21
|
-
globals={"a": ["x", "y", "cat", None]},
|
|
22
|
-
),
|
|
23
|
-
Case(
|
|
24
|
-
description="array containing an int, default value",
|
|
25
|
-
template=r"{{ a | reject: 'c' }}",
|
|
26
|
-
expect="",
|
|
27
|
-
error=True,
|
|
28
|
-
globals={"a": ["x", "y", "cat", 1]},
|
|
29
|
-
),
|
|
30
|
-
Case(
|
|
31
|
-
description="array of hashes, default value",
|
|
32
|
-
template=(
|
|
33
|
-
r"{% assign b = a | reject: 'title' %}"
|
|
34
|
-
r"{% for obj in b %}"
|
|
35
|
-
r"{% for itm in obj %}({{ itm[0] }},{{ itm[1] }}), {% endfor %}"
|
|
36
|
-
r"{% endfor %}"
|
|
37
|
-
),
|
|
38
|
-
expect="(title,false), (title,), (heading,baz), ",
|
|
39
|
-
globals={
|
|
40
|
-
"a": [
|
|
41
|
-
{"title": "foo"},
|
|
42
|
-
{"title": False},
|
|
43
|
-
{"title": None},
|
|
44
|
-
{"heading": "baz"},
|
|
45
|
-
]
|
|
46
|
-
},
|
|
47
|
-
),
|
|
48
|
-
Case(
|
|
49
|
-
description="array of hashes, explicit nil",
|
|
50
|
-
template=(
|
|
51
|
-
r"{% assign b = a | reject: 'title', nil %}"
|
|
52
|
-
r"{% for obj in b %}"
|
|
53
|
-
r"{% for itm in obj %}({{ itm[0] }},{{ itm[1] }}), {% endfor %}"
|
|
54
|
-
r"{% endfor %}"
|
|
55
|
-
),
|
|
56
|
-
expect="(title,false), (title,), (heading,baz), ",
|
|
57
|
-
globals={
|
|
58
|
-
"a": [
|
|
59
|
-
{"title": "foo"},
|
|
60
|
-
{"title": False},
|
|
61
|
-
{"title": None},
|
|
62
|
-
{"heading": "baz"},
|
|
63
|
-
]
|
|
64
|
-
},
|
|
65
|
-
),
|
|
66
|
-
Case(
|
|
67
|
-
description="array of hashes, explicit false",
|
|
68
|
-
template=(
|
|
69
|
-
r"{% assign b = a | reject: 'title', false %}"
|
|
70
|
-
r"{% for obj in b %}"
|
|
71
|
-
r"{% for itm in obj %}({{ itm[0] }},{{ itm[1] }}), {% endfor %}"
|
|
72
|
-
r"{% endfor %}"
|
|
73
|
-
),
|
|
74
|
-
expect="(title,bar), (title,), (heading,baz), ",
|
|
75
|
-
globals={
|
|
76
|
-
"a": [
|
|
77
|
-
{"title": False},
|
|
78
|
-
{"title": "bar"},
|
|
79
|
-
{"title": None},
|
|
80
|
-
{"heading": "baz"},
|
|
81
|
-
]
|
|
82
|
-
},
|
|
83
|
-
),
|
|
84
|
-
Case(
|
|
85
|
-
description="array of hashes, explicit true",
|
|
86
|
-
template=(
|
|
87
|
-
r"{% assign b = a | reject: 'title', true %}"
|
|
88
|
-
r"{% for obj in b %}"
|
|
89
|
-
r"{% for itm in obj %}({{ itm[0] }},{{ itm[1] }}), {% endfor %}"
|
|
90
|
-
r"{% endfor %}"
|
|
91
|
-
),
|
|
92
|
-
expect="(title,bar), (title,), ",
|
|
93
|
-
globals={"a": [{"title": True}, {"title": "bar"}, {"title": None}]},
|
|
94
|
-
),
|
|
95
|
-
Case(
|
|
96
|
-
description="array of hashes, string value",
|
|
97
|
-
template=(
|
|
98
|
-
r"{% assign b = a | reject: 'title', 'bar' %}"
|
|
99
|
-
r"{% for obj in b %}"
|
|
100
|
-
r"{% for itm in obj %}({{ itm[0] }},{{ itm[1] }}), {% endfor %}"
|
|
101
|
-
r"{% endfor %}"
|
|
102
|
-
),
|
|
103
|
-
expect="(title,foo), (title,), (heading,baz), ",
|
|
104
|
-
globals={
|
|
105
|
-
"a": [
|
|
106
|
-
{"title": "foo"},
|
|
107
|
-
{"title": "bar"},
|
|
108
|
-
{"title": None},
|
|
109
|
-
{"heading": "baz"},
|
|
110
|
-
]
|
|
111
|
-
},
|
|
112
|
-
),
|
|
113
|
-
Case(
|
|
114
|
-
description="array of hashes, missing property",
|
|
115
|
-
template=(
|
|
116
|
-
r"{% assign b = a | reject: 'title', 'bar' %}"
|
|
117
|
-
r"{% for obj in b %}"
|
|
118
|
-
r"{% for itm in obj %}({{ itm[0] }},{{ itm[1] }}), {% endfor %}"
|
|
119
|
-
r"{% endfor %}"
|
|
120
|
-
),
|
|
121
|
-
expect="(heading,foo), (title,), ",
|
|
122
|
-
globals={"a": [{"heading": "foo"}, {"title": "bar"}, {"title": None}]},
|
|
123
|
-
),
|
|
124
|
-
Case(
|
|
125
|
-
description="missing argument",
|
|
126
|
-
template=(
|
|
127
|
-
r"{% assign b = a | reject %}"
|
|
128
|
-
r"{% for obj in b %}{{ obj }}, {% endfor %}"
|
|
129
|
-
),
|
|
130
|
-
expect="",
|
|
131
|
-
error=True,
|
|
132
|
-
globals={"a": ["x", "y", "cat"]},
|
|
133
|
-
),
|
|
134
|
-
Case(
|
|
135
|
-
description="too many arguments",
|
|
136
|
-
template=(
|
|
137
|
-
r"{% assign b = a | reject: 'x', 'y', 'z' %}"
|
|
138
|
-
r"{% for obj in b %}{{ obj }}, {% endfor %}"
|
|
139
|
-
),
|
|
140
|
-
expect="",
|
|
141
|
-
error=True,
|
|
142
|
-
),
|
|
143
|
-
Case(
|
|
144
|
-
description="input is undefined",
|
|
145
|
-
template=(
|
|
146
|
-
r"{% assign b = nosuchthing | reject: 'c' %}"
|
|
147
|
-
r"{% for obj in b %}{{ obj }}, {% endfor %}"
|
|
148
|
-
),
|
|
149
|
-
expect="",
|
|
150
|
-
),
|
|
151
|
-
Case(
|
|
152
|
-
description="first argument is undefined",
|
|
153
|
-
template=(
|
|
154
|
-
r"{% assign b = a | reject: nosuchthing %}"
|
|
155
|
-
r"{% for obj in b %}{{ obj }}, {% endfor %}"
|
|
156
|
-
),
|
|
157
|
-
expect="",
|
|
158
|
-
globals={"a": ["x", "y", "cat"]},
|
|
159
|
-
),
|
|
160
|
-
Case(
|
|
161
|
-
description="second argument is undefined",
|
|
162
|
-
template=(
|
|
163
|
-
r"{% assign b = a | reject: 'title', nosuchthing %}"
|
|
164
|
-
r"{% for obj in b %}"
|
|
165
|
-
r"{% for itm in obj %}({{ itm[0] }},{{ itm[1] }}), {% endfor %}"
|
|
166
|
-
r"{% endfor %}"
|
|
167
|
-
),
|
|
168
|
-
expect="(title,), ",
|
|
169
|
-
globals={"a": [{"title": "foo"}, {"title": "bar"}, {"title": None}]},
|
|
170
|
-
),
|
|
171
|
-
Case(
|
|
172
|
-
description="input is a hash, default value",
|
|
173
|
-
template=(
|
|
174
|
-
r"{% assign b = h | reject: 'bar' %}"
|
|
175
|
-
r"{% for obj in b %}{{ obj }}, {% endfor %}"
|
|
176
|
-
),
|
|
177
|
-
expect="",
|
|
178
|
-
globals={"h": {"foo": 1, "bar": 2, "baz": 3}},
|
|
179
|
-
),
|
|
180
|
-
Case(
|
|
181
|
-
description="input is a hash, default value, no match",
|
|
182
|
-
template=(
|
|
183
|
-
r"{% assign b = h | reject: 'barbar' %}"
|
|
184
|
-
r"{% for obj in b %}"
|
|
185
|
-
r"{% for itm in obj %}({{ itm[0] }},{{ itm[1] }}), {% endfor %}"
|
|
186
|
-
r"{% endfor %}"
|
|
187
|
-
),
|
|
188
|
-
expect="(foo,1), (bar,2), (baz,3), ",
|
|
189
|
-
globals={"h": {"foo": 1, "bar": 2, "baz": 3}},
|
|
190
|
-
),
|
|
191
|
-
Case(
|
|
192
|
-
description="input is a hash, default value, nil match",
|
|
193
|
-
template=(
|
|
194
|
-
r"{% assign b = h | reject: 'bar' %}"
|
|
195
|
-
r"{% for obj in b %}"
|
|
196
|
-
r"{% for itm in obj %}({{ itm[0] }},{{ itm[1] }}), {% endfor %}"
|
|
197
|
-
r"{% endfor %}"
|
|
198
|
-
),
|
|
199
|
-
expect="(foo,1), (bar,), (baz,3), ",
|
|
200
|
-
globals={"h": {"foo": 1, "bar": None, "baz": 3}},
|
|
201
|
-
),
|
|
202
|
-
Case(
|
|
203
|
-
description="input is a hash, explicit nil match",
|
|
204
|
-
template=(
|
|
205
|
-
r"{% assign b = h | reject: 'bar', nil %}"
|
|
206
|
-
r"{% for obj in b %}"
|
|
207
|
-
r"{% for itm in obj %}({{ itm[0] }},{{ itm[1] }}), {% endfor %}"
|
|
208
|
-
r"{% endfor %}"
|
|
209
|
-
),
|
|
210
|
-
expect="(foo,1), (bar,), (baz,3), ",
|
|
211
|
-
globals={"h": {"foo": 1, "bar": None, "baz": 3}},
|
|
212
|
-
),
|
|
213
|
-
Case(
|
|
214
|
-
description="input is a hash, int value, no match",
|
|
215
|
-
template=(
|
|
216
|
-
r"{% assign b = h | reject: 'bar', 1 %}"
|
|
217
|
-
r"{% for obj in b %}"
|
|
218
|
-
r"{% for itm in obj %}({{ itm[0] }},{{ itm[1] }}), {% endfor %}"
|
|
219
|
-
r"{% endfor %}"
|
|
220
|
-
),
|
|
221
|
-
expect="(foo,1), (bar,2), (baz,3), ",
|
|
222
|
-
globals={"h": {"foo": 1, "bar": 2, "baz": 3}},
|
|
223
|
-
),
|
|
224
|
-
Case(
|
|
225
|
-
description="input is a hash, int value, match",
|
|
226
|
-
template=(
|
|
227
|
-
r"{% assign b = h | reject: 'bar', 2 %}"
|
|
228
|
-
r"{% for obj in b %}"
|
|
229
|
-
r"{% for itm in obj %}({{ itm[0] }},{{ itm[1] }}), {% endfor %}"
|
|
230
|
-
r"{% endfor %}"
|
|
231
|
-
),
|
|
232
|
-
expect="",
|
|
233
|
-
globals={"h": {"foo": 1, "bar": 2, "baz": 3}},
|
|
234
|
-
),
|
|
235
|
-
Case(
|
|
236
|
-
description="nested array of hashes gets flattened",
|
|
237
|
-
template=(
|
|
238
|
-
r"{% assign b = a | reject: 'title', 'bar' %}"
|
|
239
|
-
r"{% for obj in b %}"
|
|
240
|
-
r"{% for itm in obj %}({{ itm[0] }},{{ itm[1] }}), {% endfor %}"
|
|
241
|
-
r"{% endfor %}"
|
|
242
|
-
),
|
|
243
|
-
expect="(title,foo), (title,), ",
|
|
244
|
-
globals={"a": [[{"title": "foo"}, {"title": "bar"}], [[{"title": None}]]]},
|
|
245
|
-
),
|
|
246
|
-
Case(
|
|
247
|
-
description="string input becomes a single element array, substring match",
|
|
248
|
-
template=(
|
|
249
|
-
r"{% assign b = s | reject: 'oo' %}"
|
|
250
|
-
r"{% for obj in b %}"
|
|
251
|
-
r"{{ obj }}, "
|
|
252
|
-
r"{% endfor %}"
|
|
253
|
-
),
|
|
254
|
-
expect="",
|
|
255
|
-
globals={"s": "foobar"},
|
|
256
|
-
),
|
|
257
|
-
Case(
|
|
258
|
-
description="string input becomes a single element array, no match",
|
|
259
|
-
template=(
|
|
260
|
-
r"{% assign b = s | reject: 'xx' %}"
|
|
261
|
-
r"{% for obj in b %}"
|
|
262
|
-
r"{{ obj }}, "
|
|
263
|
-
r"{% endfor %}"
|
|
264
|
-
),
|
|
265
|
-
expect="foobar, ",
|
|
266
|
-
globals={"s": "foobar"},
|
|
267
|
-
),
|
|
268
|
-
]
|
liquid/golden/remove_filter.py
DELETED
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
"""Golden tests cases for testing liquid's built-in `remove` filter."""
|
|
2
|
-
|
|
3
|
-
from liquid.golden.case import Case
|
|
4
|
-
|
|
5
|
-
cases = [
|
|
6
|
-
Case(
|
|
7
|
-
description="remove substrings",
|
|
8
|
-
template=(
|
|
9
|
-
r'{{ "I strained to see the train through the rain" | remove: "rain" }}'
|
|
10
|
-
),
|
|
11
|
-
expect="I sted to see the t through the ",
|
|
12
|
-
),
|
|
13
|
-
Case(
|
|
14
|
-
description="not a string",
|
|
15
|
-
template=r"{{ 5 | remove: 'there' }}",
|
|
16
|
-
expect="5",
|
|
17
|
-
),
|
|
18
|
-
Case(
|
|
19
|
-
description="argument not a string",
|
|
20
|
-
template=r'{{ "hello" | remove: 5 }}',
|
|
21
|
-
expect="hello",
|
|
22
|
-
),
|
|
23
|
-
Case(
|
|
24
|
-
description="missing argument",
|
|
25
|
-
template=r'{{ "hello" | remove }}',
|
|
26
|
-
expect="",
|
|
27
|
-
error=True,
|
|
28
|
-
),
|
|
29
|
-
Case(
|
|
30
|
-
description="too many arguments",
|
|
31
|
-
template=r'{{ "hello" | remove: "how", "are", "you" }}',
|
|
32
|
-
expect="",
|
|
33
|
-
error=True,
|
|
34
|
-
),
|
|
35
|
-
Case(
|
|
36
|
-
description="undefined left value",
|
|
37
|
-
template=r'{{ nosuchthing | remove: "rain" }}',
|
|
38
|
-
expect="",
|
|
39
|
-
),
|
|
40
|
-
Case(
|
|
41
|
-
description="undefined argument",
|
|
42
|
-
template=r'{{ "hello" | remove: nosuchthing }}',
|
|
43
|
-
expect="hello",
|
|
44
|
-
),
|
|
45
|
-
]
|
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
"""Golden tests cases for testing liquid's built-in `remove_first` filter."""
|
|
2
|
-
|
|
3
|
-
from liquid.golden.case import Case
|
|
4
|
-
|
|
5
|
-
cases = [
|
|
6
|
-
Case(
|
|
7
|
-
description="remove substrings",
|
|
8
|
-
template=(
|
|
9
|
-
r'{{ "I strained to see the train through the rain" | '
|
|
10
|
-
r'remove_first: "rain" }}'
|
|
11
|
-
),
|
|
12
|
-
expect="I sted to see the train through the rain",
|
|
13
|
-
),
|
|
14
|
-
Case(
|
|
15
|
-
description="not a string",
|
|
16
|
-
template=r"{{ 5 | remove_first: 'rain' }}",
|
|
17
|
-
expect="5",
|
|
18
|
-
),
|
|
19
|
-
Case(
|
|
20
|
-
description="argument not a string",
|
|
21
|
-
template=r'{{ "hello" | remove_first: 5 }}',
|
|
22
|
-
expect="hello",
|
|
23
|
-
),
|
|
24
|
-
Case(
|
|
25
|
-
description="missing argument",
|
|
26
|
-
template=r'{{ "hello" | remove_first }}',
|
|
27
|
-
expect="",
|
|
28
|
-
error=True,
|
|
29
|
-
),
|
|
30
|
-
Case(
|
|
31
|
-
description="too many arguments",
|
|
32
|
-
template=r'{{ "hello" | remove_first: "how", "are", "you" }}',
|
|
33
|
-
expect="",
|
|
34
|
-
error=True,
|
|
35
|
-
),
|
|
36
|
-
Case(
|
|
37
|
-
description="undefined left value",
|
|
38
|
-
template=r'{{ nosuchthing | remove_first: "rain" }}',
|
|
39
|
-
expect="",
|
|
40
|
-
),
|
|
41
|
-
Case(
|
|
42
|
-
description="undefined argument",
|
|
43
|
-
template=r'{{ "hello" | remove_first: nosuchthing }}',
|
|
44
|
-
expect="hello",
|
|
45
|
-
),
|
|
46
|
-
]
|
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
"""Golden tests cases for testing liquid's built-in `remove_last` filter."""
|
|
2
|
-
|
|
3
|
-
from liquid.golden.case import Case
|
|
4
|
-
|
|
5
|
-
cases = [
|
|
6
|
-
Case(
|
|
7
|
-
description="remove substrings",
|
|
8
|
-
template=(
|
|
9
|
-
r'{{ "I strained to see the train through the rain" | '
|
|
10
|
-
r'remove_last: "rain" }}'
|
|
11
|
-
),
|
|
12
|
-
expect="I strained to see the train through the ",
|
|
13
|
-
),
|
|
14
|
-
Case(
|
|
15
|
-
description="not a string",
|
|
16
|
-
template=r"{{ 5 | remove_last: 'rain' }}",
|
|
17
|
-
expect="5",
|
|
18
|
-
),
|
|
19
|
-
Case(
|
|
20
|
-
description="argument not a string",
|
|
21
|
-
template=r'{{ "hello" | remove_last: 5 }}',
|
|
22
|
-
expect="hello",
|
|
23
|
-
),
|
|
24
|
-
Case(
|
|
25
|
-
description="missing argument",
|
|
26
|
-
template=r'{{ "hello" | remove_last }}',
|
|
27
|
-
expect="",
|
|
28
|
-
error=True,
|
|
29
|
-
),
|
|
30
|
-
Case(
|
|
31
|
-
description="too many arguments",
|
|
32
|
-
template=r'{{ "hello" | remove_last: "how", "are", "you" }}',
|
|
33
|
-
expect="",
|
|
34
|
-
error=True,
|
|
35
|
-
),
|
|
36
|
-
Case(
|
|
37
|
-
description="undefined left value",
|
|
38
|
-
template=r'{{ nosuchthing | remove_last: "rain" }}',
|
|
39
|
-
expect="",
|
|
40
|
-
),
|
|
41
|
-
Case(
|
|
42
|
-
description="undefined argument",
|
|
43
|
-
template=r'{{ "hello" | remove_last: nosuchthing }}',
|
|
44
|
-
expect="hello",
|
|
45
|
-
),
|
|
46
|
-
]
|
liquid/golden/render_tag.py
DELETED
|
@@ -1,210 +0,0 @@
|
|
|
1
|
-
"""Golden tests cases for testing liquid's `render` tag."""
|
|
2
|
-
|
|
3
|
-
from liquid.golden.case import TEMPLATE_DROP_ATTRS
|
|
4
|
-
from liquid.golden.case import Case
|
|
5
|
-
|
|
6
|
-
cases = [
|
|
7
|
-
Case(
|
|
8
|
-
description="string literal name",
|
|
9
|
-
template=r"{% render 'product-hero', product: product %}",
|
|
10
|
-
expect="foo\n- sports - garden ",
|
|
11
|
-
globals={"product": {"title": "foo", "tags": ["sports", "garden"]}},
|
|
12
|
-
partials={
|
|
13
|
-
"product-hero": "\n".join(
|
|
14
|
-
[
|
|
15
|
-
r"{{ product.title }}",
|
|
16
|
-
r"{% for tag in product.tags %}- {{ tag }} {% endfor %}",
|
|
17
|
-
]
|
|
18
|
-
),
|
|
19
|
-
},
|
|
20
|
-
),
|
|
21
|
-
Case(
|
|
22
|
-
description="bound variable",
|
|
23
|
-
template=r"{% render 'product-title' with collection.products[1] %}",
|
|
24
|
-
expect="car",
|
|
25
|
-
globals={"collection": {"products": [{"title": "bike"}, {"title": "car"}]}},
|
|
26
|
-
partials={"product-title": r"{{ product-title.title }}"},
|
|
27
|
-
),
|
|
28
|
-
Case(
|
|
29
|
-
description="bound variable does not exist",
|
|
30
|
-
template=r"{% render 'product-title' with no.such.thing %}",
|
|
31
|
-
expect="",
|
|
32
|
-
globals={},
|
|
33
|
-
partials={"product-title": r"{{ product-title.title }}"},
|
|
34
|
-
),
|
|
35
|
-
Case(
|
|
36
|
-
description="bound array variable",
|
|
37
|
-
template=r"{% render 'prod' for collection.products %}",
|
|
38
|
-
expect="bikecar",
|
|
39
|
-
globals={"collection": {"products": [{"title": "bike"}, {"title": "car"}]}},
|
|
40
|
-
partials={"prod": r"{{ prod.title }}"},
|
|
41
|
-
),
|
|
42
|
-
Case(
|
|
43
|
-
description="bound variable with alias",
|
|
44
|
-
template=r"{% render 'product-alias' with collection.products[1] as product %}",
|
|
45
|
-
expect="car",
|
|
46
|
-
globals={"collection": {"products": [{"title": "bike"}, {"title": "car"}]}},
|
|
47
|
-
partials={
|
|
48
|
-
"product-alias": r"{{ product.title }}",
|
|
49
|
-
},
|
|
50
|
-
),
|
|
51
|
-
Case(
|
|
52
|
-
description="some keyword arguments",
|
|
53
|
-
template=r"{% render 'product-args', foo: 'hello', bar: 'there' %}",
|
|
54
|
-
expect="hello there",
|
|
55
|
-
globals={},
|
|
56
|
-
partials={
|
|
57
|
-
"product-args": r"{{ foo }} {{ bar }}",
|
|
58
|
-
},
|
|
59
|
-
),
|
|
60
|
-
Case(
|
|
61
|
-
description="some keyword arguments including a range literal",
|
|
62
|
-
template=r"{% render 'product-args', foo: (1..3), bar: 'there' %}",
|
|
63
|
-
expect="1#2#3 there",
|
|
64
|
-
globals={},
|
|
65
|
-
partials={
|
|
66
|
-
"product-args": r"{{ foo | join: '#' }} {{ bar }}",
|
|
67
|
-
},
|
|
68
|
-
),
|
|
69
|
-
Case(
|
|
70
|
-
description="some keyword arguments no leading coma",
|
|
71
|
-
template=r"{% render 'product-args' foo: 'hello', bar: 'there' %}",
|
|
72
|
-
expect="hello there",
|
|
73
|
-
globals={},
|
|
74
|
-
partials={"product-args": r"{{ foo }} {{ bar }}"},
|
|
75
|
-
),
|
|
76
|
-
Case(
|
|
77
|
-
description="template drop",
|
|
78
|
-
template=r"{% render 'some/template-attrs.alt.txt' %}",
|
|
79
|
-
expect="template-attrs.alt some template-attrs alt",
|
|
80
|
-
globals={},
|
|
81
|
-
partials={"some/template-attrs.alt.txt": TEMPLATE_DROP_ATTRS},
|
|
82
|
-
standard=False,
|
|
83
|
-
),
|
|
84
|
-
Case(
|
|
85
|
-
description="template drop no parent",
|
|
86
|
-
template=r"{% render 'template-attrs.alt.txt' %}",
|
|
87
|
-
expect="template-attrs.alt template-attrs alt",
|
|
88
|
-
globals={},
|
|
89
|
-
partials={"template-attrs.alt.txt": TEMPLATE_DROP_ATTRS},
|
|
90
|
-
standard=False,
|
|
91
|
-
),
|
|
92
|
-
Case(
|
|
93
|
-
description="template drop no suffix",
|
|
94
|
-
template=r"{% render 'some/template-attrs.txt' %}",
|
|
95
|
-
expect="template-attrs some template-attrs ",
|
|
96
|
-
globals={},
|
|
97
|
-
partials={"some/template-attrs.txt": TEMPLATE_DROP_ATTRS},
|
|
98
|
-
standard=False,
|
|
99
|
-
),
|
|
100
|
-
Case(
|
|
101
|
-
description="template drop no suffix or extension",
|
|
102
|
-
template=r"{% render 'some/template-attrs' %}",
|
|
103
|
-
expect="template-attrs some template-attrs ",
|
|
104
|
-
globals={},
|
|
105
|
-
partials={"some/template-attrs": TEMPLATE_DROP_ATTRS},
|
|
106
|
-
standard=False,
|
|
107
|
-
),
|
|
108
|
-
Case(
|
|
109
|
-
description="parent variables go out of scope",
|
|
110
|
-
template=(
|
|
111
|
-
r"{% assign greeting = 'good morning' %}"
|
|
112
|
-
r"{{ greeting }} "
|
|
113
|
-
r"{% render 'outer-scope' %}"
|
|
114
|
-
r"{{ greeting }}"
|
|
115
|
-
),
|
|
116
|
-
expect="good morning good morning",
|
|
117
|
-
partials={"outer-scope": r"{{ greeting }}"},
|
|
118
|
-
),
|
|
119
|
-
Case(
|
|
120
|
-
description="for loop variables go out of scope",
|
|
121
|
-
template=(
|
|
122
|
-
r"{% for i in (1..3) %}"
|
|
123
|
-
r"{{ i }}"
|
|
124
|
-
r"{% render 'loop-scope' %}"
|
|
125
|
-
r"{{ i }}"
|
|
126
|
-
r"{% endfor %}"
|
|
127
|
-
r"{{ i }}"
|
|
128
|
-
),
|
|
129
|
-
expect="112233",
|
|
130
|
-
partials={"loop-scope": r"{{ i }}"},
|
|
131
|
-
),
|
|
132
|
-
Case(
|
|
133
|
-
description="assigned variables do not leak into outer scope",
|
|
134
|
-
template=(
|
|
135
|
-
r"{% render 'assign-outer-scope', customer: customer %} {{ last_name }}"
|
|
136
|
-
),
|
|
137
|
-
expect="Hello, Holly ",
|
|
138
|
-
globals={"customer": {"first_name": "Holly"}},
|
|
139
|
-
partials={
|
|
140
|
-
"assign-outer-scope": (
|
|
141
|
-
r"Hello, {{ customer.first_name }}{% assign last_name = 'Smith' %}"
|
|
142
|
-
)
|
|
143
|
-
},
|
|
144
|
-
),
|
|
145
|
-
Case(
|
|
146
|
-
description="increment is isolated between renders",
|
|
147
|
-
template=r"{% increment foo %} {% render 'increment' %} {% increment foo %}",
|
|
148
|
-
expect="0 0 1",
|
|
149
|
-
partials={"increment": r"{% increment foo %}"},
|
|
150
|
-
),
|
|
151
|
-
Case(
|
|
152
|
-
description="decrement is isolated between renders",
|
|
153
|
-
template=r"{% decrement foo %} {% render 'decrement' %} {% decrement foo %}",
|
|
154
|
-
expect="-1 -1 -2",
|
|
155
|
-
partials={"decrement": r"{% decrement foo %}"},
|
|
156
|
-
),
|
|
157
|
-
Case(
|
|
158
|
-
description="forloop helper",
|
|
159
|
-
template=r"{% render 'product' for collection.products %}",
|
|
160
|
-
expect="Product: bike first index:1 Product: car last index:2 ",
|
|
161
|
-
globals={"collection": {"products": [{"title": "bike"}, {"title": "car"}]}},
|
|
162
|
-
partials={
|
|
163
|
-
"product": (
|
|
164
|
-
r"Product: {{ product.title }} "
|
|
165
|
-
r"{% if forloop.first %}first{% endif %}"
|
|
166
|
-
r"{% if forloop.last %}last{% endif %}"
|
|
167
|
-
r" index:{{ forloop.index }} "
|
|
168
|
-
),
|
|
169
|
-
},
|
|
170
|
-
),
|
|
171
|
-
Case(
|
|
172
|
-
description="render loops don't add parentloop",
|
|
173
|
-
template=r"{% render 'product' for collection.products %}",
|
|
174
|
-
expect="bike-0 0 1 2 car-1 0 1 2 ",
|
|
175
|
-
globals={"collection": {"products": [{"title": "bike"}, {"title": "car"}]}},
|
|
176
|
-
partials={
|
|
177
|
-
"product": (
|
|
178
|
-
r"{{ product.title }}-{{ forloop.index0 }} "
|
|
179
|
-
r"{% for x in (1..3) %}"
|
|
180
|
-
r"{{ forloop.index0 }}{{ forloop.parentloop.index0 }} "
|
|
181
|
-
r"{% endfor %}"
|
|
182
|
-
),
|
|
183
|
-
},
|
|
184
|
-
),
|
|
185
|
-
Case(
|
|
186
|
-
description="render loops can't access parentloop",
|
|
187
|
-
template=(
|
|
188
|
-
r"{% for x in (1..3) %}"
|
|
189
|
-
r"{% render 'product' for collection.products %}"
|
|
190
|
-
r"{% endfor %}"
|
|
191
|
-
),
|
|
192
|
-
expect="bike-0 car-1 bike-0 car-1 bike-0 car-1 ",
|
|
193
|
-
globals={"collection": {"products": [{"title": "bike"}, {"title": "car"}]}},
|
|
194
|
-
partials={
|
|
195
|
-
"product": (
|
|
196
|
-
r"{{ product.title }}-{{ forloop.index0 }} "
|
|
197
|
-
r"{{ forloop.parentloop.index0 }}"
|
|
198
|
-
),
|
|
199
|
-
},
|
|
200
|
-
),
|
|
201
|
-
Case(
|
|
202
|
-
description="assign to keyword argument",
|
|
203
|
-
template=r"{% render 'product-args', foo: 'hello' %}{{ foo }}",
|
|
204
|
-
expect="hello goodbye",
|
|
205
|
-
globals={},
|
|
206
|
-
partials={
|
|
207
|
-
"product-args": r"{{ foo }}{% assign foo='goodbye' %} {{ foo }}",
|
|
208
|
-
},
|
|
209
|
-
),
|
|
210
|
-
]
|
liquid/golden/replace_filter.py
DELETED
|
@@ -1,65 +0,0 @@
|
|
|
1
|
-
"""Golden tests cases for testing liquid's built-in `replace` filter."""
|
|
2
|
-
|
|
3
|
-
from liquid.golden.case import Case
|
|
4
|
-
|
|
5
|
-
cases = [
|
|
6
|
-
Case(
|
|
7
|
-
description="replace substrings",
|
|
8
|
-
template=(
|
|
9
|
-
r'{{ "Take my protein pills and put my helmet on" '
|
|
10
|
-
r'| replace: "my", "your" }}'
|
|
11
|
-
),
|
|
12
|
-
expect="Take your protein pills and put your helmet on",
|
|
13
|
-
),
|
|
14
|
-
Case(
|
|
15
|
-
description="not a string",
|
|
16
|
-
template=r"{{ 5 | replace: 'rain', 'foo' }}",
|
|
17
|
-
expect="5",
|
|
18
|
-
),
|
|
19
|
-
Case(
|
|
20
|
-
description="left value is an object",
|
|
21
|
-
template=r"{{ a | replace: '{', '!' }}",
|
|
22
|
-
expect="!}",
|
|
23
|
-
globals={"a": {}},
|
|
24
|
-
),
|
|
25
|
-
Case(
|
|
26
|
-
description="argument not a string",
|
|
27
|
-
template=r'{{ "hello" | replace: 5, "your" }}',
|
|
28
|
-
expect="hello",
|
|
29
|
-
),
|
|
30
|
-
Case(
|
|
31
|
-
description="missing argument",
|
|
32
|
-
template=r'{{ "hello" | replace: "ll" }}',
|
|
33
|
-
expect="heo",
|
|
34
|
-
),
|
|
35
|
-
Case(
|
|
36
|
-
description="missing arguments",
|
|
37
|
-
template=r'{{ "hello" | replace }}',
|
|
38
|
-
expect="",
|
|
39
|
-
error=True,
|
|
40
|
-
),
|
|
41
|
-
Case(
|
|
42
|
-
description="too many arguments",
|
|
43
|
-
template=r'{{ "hello" | replace: "how", "are", "you" }}',
|
|
44
|
-
expect="",
|
|
45
|
-
error=True,
|
|
46
|
-
),
|
|
47
|
-
Case(
|
|
48
|
-
description="undefined left value",
|
|
49
|
-
template=r'{{ nosuchthing | replace: "my", "your" }}',
|
|
50
|
-
expect="",
|
|
51
|
-
),
|
|
52
|
-
Case(
|
|
53
|
-
description="undefined first argument",
|
|
54
|
-
template=r'{{ "Take my protein" | replace: nosuchthing, "#" }}',
|
|
55
|
-
expect="#T#a#k#e# #m#y# #p#r#o#t#e#i#n#",
|
|
56
|
-
),
|
|
57
|
-
Case(
|
|
58
|
-
description="undefined second argument",
|
|
59
|
-
template=(
|
|
60
|
-
r'{{ "Take my protein pills and put my helmet on" '
|
|
61
|
-
r'| replace: "my", nosuchthing }}'
|
|
62
|
-
),
|
|
63
|
-
expect="Take protein pills and put helmet on",
|
|
64
|
-
),
|
|
65
|
-
]
|