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.
Files changed (98) hide show
  1. liquid/__init__.py +1 -1
  2. liquid/builtin/expressions/loop.py +2 -5
  3. liquid/builtin/loaders/mixins.py +1 -2
  4. liquid/extra/tags/macro_tag.py +2 -0
  5. liquid/messages.py +1 -1
  6. liquid/static_analysis.py +16 -10
  7. {python_liquid-2.0.0.dist-info → python_liquid-2.0.2.dist-info}/METADATA +6 -9
  8. python_liquid-2.0.2.dist-info/RECORD +95 -0
  9. liquid/golden/__init__.py +0 -173
  10. liquid/golden/abs_filter.py +0 -73
  11. liquid/golden/append_filter.py +0 -43
  12. liquid/golden/assign_tag.py +0 -45
  13. liquid/golden/at_least_filter.py +0 -78
  14. liquid/golden/at_most_filter.py +0 -68
  15. liquid/golden/base64_decode_filter.py +0 -43
  16. liquid/golden/base64_encode_filter.py +0 -42
  17. liquid/golden/base64_url_safe_decode_filter.py +0 -43
  18. liquid/golden/base64_url_safe_encode_filter.py +0 -42
  19. liquid/golden/capitalize_filter.py +0 -27
  20. liquid/golden/capture_tag.py +0 -39
  21. liquid/golden/case.py +0 -28
  22. liquid/golden/case_tag.py +0 -226
  23. liquid/golden/ceil_filter.py +0 -63
  24. liquid/golden/comment_tag.py +0 -119
  25. liquid/golden/compact_filter.py +0 -54
  26. liquid/golden/concat_filter.py +0 -63
  27. liquid/golden/cycle_tag.py +0 -114
  28. liquid/golden/date_filter.py +0 -63
  29. liquid/golden/decrement_tag.py +0 -16
  30. liquid/golden/default_filter.py +0 -112
  31. liquid/golden/divided_by_filter.py +0 -101
  32. liquid/golden/doc_tag.py +0 -61
  33. liquid/golden/downcase_filter.py +0 -27
  34. liquid/golden/echo_tag.py +0 -116
  35. liquid/golden/escape_filter.py +0 -27
  36. liquid/golden/escape_once_filter.py +0 -32
  37. liquid/golden/find_filter.py +0 -90
  38. liquid/golden/find_index_filter.py +0 -96
  39. liquid/golden/first_filter.py +0 -51
  40. liquid/golden/floor_filter.py +0 -63
  41. liquid/golden/for_tag.py +0 -642
  42. liquid/golden/has_filter.py +0 -139
  43. liquid/golden/identifiers.py +0 -249
  44. liquid/golden/if_tag.py +0 -531
  45. liquid/golden/ifchanged_tag.py +0 -46
  46. liquid/golden/illegal.py +0 -34
  47. liquid/golden/include_tag.py +0 -196
  48. liquid/golden/increment_tag.py +0 -48
  49. liquid/golden/inline_comment_tag.py +0 -127
  50. liquid/golden/join_filter.py +0 -69
  51. liquid/golden/last_filter.py +0 -51
  52. liquid/golden/liquid_tag.py +0 -215
  53. liquid/golden/lstrip_filter.py +0 -37
  54. liquid/golden/map_filter.py +0 -50
  55. liquid/golden/minus_filter.py +0 -58
  56. liquid/golden/modulo_filter.py +0 -60
  57. liquid/golden/newline_to_br_filter.py +0 -37
  58. liquid/golden/not_liquid.py +0 -16
  59. liquid/golden/output_statement.py +0 -295
  60. liquid/golden/plus_filter.py +0 -63
  61. liquid/golden/prepend_filter.py +0 -43
  62. liquid/golden/range_objects.py +0 -79
  63. liquid/golden/raw_tag.py +0 -31
  64. liquid/golden/reject_filter.py +0 -268
  65. liquid/golden/remove_filter.py +0 -45
  66. liquid/golden/remove_first_filter.py +0 -46
  67. liquid/golden/remove_last_filter.py +0 -46
  68. liquid/golden/render_tag.py +0 -210
  69. liquid/golden/replace_filter.py +0 -65
  70. liquid/golden/replace_first_filter.py +0 -59
  71. liquid/golden/replace_last_filter.py +0 -60
  72. liquid/golden/reverse_filter.py +0 -42
  73. liquid/golden/round_filter.py +0 -87
  74. liquid/golden/rstrip_filter.py +0 -37
  75. liquid/golden/size_filter.py +0 -42
  76. liquid/golden/slice_filter.py +0 -119
  77. liquid/golden/sort_filter.py +0 -86
  78. liquid/golden/sort_natural_filter.py +0 -105
  79. liquid/golden/special.py +0 -91
  80. liquid/golden/split_filter.py +0 -128
  81. liquid/golden/strip_filter.py +0 -37
  82. liquid/golden/strip_html_filter.py +0 -74
  83. liquid/golden/strip_newlines_filter.py +0 -37
  84. liquid/golden/sum_filter.py +0 -97
  85. liquid/golden/tablerow_tag.py +0 -399
  86. liquid/golden/times_filter.py +0 -53
  87. liquid/golden/truncate_filter.py +0 -61
  88. liquid/golden/truncatewords_filter.py +0 -94
  89. liquid/golden/uniq_filter.py +0 -87
  90. liquid/golden/unless_tag.py +0 -101
  91. liquid/golden/upcase_filter.py +0 -27
  92. liquid/golden/url_decode_filter.py +0 -27
  93. liquid/golden/url_encode_filter.py +0 -27
  94. liquid/golden/where_filter.py +0 -122
  95. liquid/golden/whitespace_control.py +0 -281
  96. python_liquid-2.0.0.dist-info/RECORD +0 -182
  97. {python_liquid-2.0.0.dist-info → python_liquid-2.0.2.dist-info}/WHEEL +0 -0
  98. {python_liquid-2.0.0.dist-info → python_liquid-2.0.2.dist-info}/licenses/LICENSE +0 -0
@@ -1,295 +0,0 @@
1
- """Golden tests cases for testing liquid output statements."""
2
-
3
- import datetime
4
-
5
- from liquid.golden.case import Case
6
-
7
- cases = [
8
- Case(
9
- description="render a string literal",
10
- template=r"{{ 'hello' }}",
11
- expect="hello",
12
- ),
13
- Case(
14
- description="render an integer literal",
15
- template=r"{{ 123 }}",
16
- expect="123",
17
- ),
18
- Case(
19
- description="render a negative integer literal",
20
- template=r"{{ -123 }}",
21
- expect="-123",
22
- ),
23
- Case(
24
- description="render a float literal",
25
- template=r"{{ 1.23 }}",
26
- expect="1.23",
27
- ),
28
- Case(
29
- description="render nil",
30
- template=r"{{ nil }}",
31
- expect="",
32
- ),
33
- Case(
34
- description="render a variable from the global namespace",
35
- template=r"{{ product.title }}",
36
- expect="foo",
37
- globals={"product": {"title": "foo"}},
38
- ),
39
- Case(
40
- description="render a variable from the local namespace",
41
- template=r"{% assign name = 'Brian' %}{{ name }}",
42
- expect="Brian",
43
- ),
44
- Case(
45
- description="render an undefined variable",
46
- template=r"{{ age }}",
47
- expect="",
48
- ),
49
- Case(
50
- description="render an undefined property",
51
- template=r"{{ product.age }}",
52
- expect="",
53
- globals={"product": {"title": "foo"}},
54
- ),
55
- Case(
56
- description="access an array item by index",
57
- template=r"{{ product.tags[1] }}",
58
- expect="garden",
59
- globals={"product": {"tags": ["sports", "garden"]}},
60
- ),
61
- Case(
62
- description="access an array item by negative index",
63
- template=r"{{ product.tags[-2] }}",
64
- expect="sports",
65
- globals={"product": {"tags": ["sports", "garden"]}},
66
- ),
67
- Case(
68
- description="access array item by index stored in a local variable",
69
- template="{% assign i = 1 %}{{ product.tags[i] }}",
70
- expect="garden",
71
- globals={"product": {"tags": ["sports", "garden"]}},
72
- ),
73
- Case(
74
- description="render a global variable with a filter",
75
- template=r"{{ product.title | upcase }}",
76
- expect="FOO",
77
- globals={"product": {"title": "foo"}},
78
- ),
79
- Case(
80
- description="dump an array from the global context",
81
- template=r"{{ product.tags | join: '#' }}",
82
- expect="sports#garden",
83
- globals={"product": {"tags": ["sports", "garden"]}},
84
- ),
85
- Case(
86
- description="assign a variable the value of an existing variable",
87
- template=(
88
- r"{% capture some %}hello{% endcapture %}"
89
- r"{% assign other = some %}"
90
- r"{% assign some = 'foo' %}"
91
- r"{{ some }}-{{ other }}"
92
- ),
93
- expect="foo-hello",
94
- ),
95
- Case(
96
- description="traverse variables with bracketed identifiers",
97
- template=r"{{ site.data.menu[include.menu][include.locale] }}",
98
- expect="it works!",
99
- globals={
100
- "site": {"data": {"menu": {"foo": {"bar": "it works!"}}}},
101
- "include": {"menu": "foo", "locale": "bar"},
102
- },
103
- ),
104
- Case(
105
- description="render the special built in variable 'now'",
106
- template=r"{{ now | date: '%d/%m/%Y' }}",
107
- expect=datetime.datetime.now().strftime(r"%d/%m/%Y"),
108
- standard=False,
109
- ),
110
- Case(
111
- description="render the special built in variable 'today'",
112
- template=r"{{ today | date: '%d/%m/%Y' }}",
113
- expect=datetime.date.today().strftime(r"%d/%m/%Y"),
114
- standard=False,
115
- ),
116
- Case(
117
- description="render a default given a literal false",
118
- template=r"{{ false | default: 'bar' }}",
119
- expect="bar",
120
- ),
121
- Case(
122
- description=(
123
- "render a default given a literal false with 'allow false' equal to true"
124
- ),
125
- template=r"{{ false | default: 'bar', allow_false: true }}",
126
- expect="false",
127
- ),
128
- Case(
129
- description=(
130
- "render a default given a literal false with 'allow false' equal to false"
131
- ),
132
- template=r"{{ false | default: 'bar', allow_false: false }}",
133
- expect="bar",
134
- ),
135
- Case(
136
- description=("unexpected left value for the `join` filter passes through"),
137
- template=r"{{ 12 | join: '#' }}",
138
- expect="12",
139
- ),
140
- Case(
141
- description="render an output start sequence as a string literal",
142
- template=r"{{ '{{' }}",
143
- expect=r"{{",
144
- ),
145
- Case(
146
- description="access an undefined variable by index",
147
- template=r"{{ nosuchthing[0] }}",
148
- expect="",
149
- ),
150
- Case(
151
- description="render a range object",
152
- template=r"{{ (1..5) | join: '#' }}",
153
- expect="1#2#3#4#5",
154
- ),
155
- Case(
156
- description="render a range object that uses a float",
157
- template=r"{{ (1.4..5) | join: '#' }}",
158
- expect="1#2#3#4#5",
159
- ),
160
- Case(
161
- description="render a range object that uses an identifier",
162
- template=r"{{ (foo..5) | join: '#' }}",
163
- expect="2#3#4#5",
164
- globals={"foo": 2},
165
- ),
166
- Case(
167
- description="reverse a range",
168
- template=r"{{ (foo..5) | reverse | join: '#' }}",
169
- expect="5#4#3#2",
170
- globals={"foo": 2},
171
- ),
172
- Case(
173
- description="chained bracketed identifier index",
174
- template=r"{{ products[0].title }}",
175
- expect="shoe",
176
- globals={"products": [{"title": "shoe"}, {"title": "hat"}]},
177
- ),
178
- Case(
179
- description="chained bracketed identifier index no dot",
180
- template=r"{{ products[0]title }}",
181
- expect="shoe",
182
- globals={"products": [{"title": "shoe"}, {"title": "hat"}]},
183
- strict=True,
184
- error=True,
185
- ),
186
- Case(
187
- description="chained identifier dot separated index",
188
- template=r"{{ products.0.title }}",
189
- expect="",
190
- globals={"products": [{"title": "shoe"}, {"title": "hat"}]},
191
- strict=True,
192
- error=True,
193
- ),
194
- Case(
195
- description="dot followed by bracket",
196
- template=r"{{ product.['title'] }}",
197
- expect="shoe",
198
- globals={"product": {"title": "shoe"}},
199
- strict=True,
200
- error=True,
201
- ),
202
- Case(
203
- description="bracketed variable resolves to a string",
204
- template=r"{{ foo[something] }}",
205
- expect="goodbye",
206
- globals={"foo": {"hello": "goodbye"}, "something": "hello"},
207
- ),
208
- Case(
209
- description=(
210
- "bracketed variable resolves to a string without leading identifier"
211
- ),
212
- template=r"{{ [something] }}",
213
- expect="goodbye",
214
- globals={"something": "hello", "hello": "goodbye"},
215
- ),
216
- Case(
217
- description="nested bracketed variable resolving to a string",
218
- template=r"{{ [list[settings.zero]] }}",
219
- expect="bar",
220
- globals={"list": ["foo"], "settings": {"zero": 0}, "foo": "bar"},
221
- ),
222
- Case(
223
- description="quoted, bracketed variable name",
224
- template=r"{{ foo['bar'] }}",
225
- expect="42",
226
- globals={"foo": {"bar": 42}},
227
- ),
228
- Case(
229
- description="quoted, bracketed variable name with whitespace",
230
- template=r"{{ foo['bar baz'] }}",
231
- expect="42",
232
- globals={"foo": {"bar baz": 42}},
233
- ),
234
- Case(
235
- description="top-level quoted, bracketed variable name with whitespace",
236
- template=r"{{ ['bar baz'] }}",
237
- expect="42",
238
- globals={"bar baz": 42},
239
- ),
240
- Case(
241
- description=(
242
- "top-level quoted, bracketed variable name with whitespace "
243
- "followed by dot notation"
244
- ),
245
- template=r"{{ ['bar baz'].qux }}",
246
- expect="42",
247
- globals={"bar baz": {"qux": 42}},
248
- ),
249
- Case(
250
- description="whitespace between word and dot",
251
- template="{{ foo \n\t.bar }}",
252
- expect="42",
253
- globals={"foo": {"bar": 42}},
254
- ),
255
- Case(
256
- description="whitespace between dot and word",
257
- template="{{ foo. \n\tbar }}",
258
- expect="42",
259
- globals={"foo": {"bar": 42}},
260
- ),
261
- Case(
262
- description="whitespace between bracket notation",
263
- template="{{ ['foo'] \n\t['bar'] }}",
264
- expect="42",
265
- globals={"foo": {"bar": 42}},
266
- ),
267
- Case(
268
- description="whitespace between words",
269
- template="{{ foo \n\tbar }}",
270
- expect="42",
271
- globals={"foo": {"bar": 42}},
272
- strict=True,
273
- error=True,
274
- ),
275
- Case(
276
- description="double dot",
277
- template="{{ foo..bar }}",
278
- expect="42",
279
- globals={"foo": {"bar": 42}},
280
- strict=True,
281
- error=True,
282
- ),
283
- Case(
284
- description="array index out of bounds",
285
- template="{{ a[3] }}",
286
- expect="",
287
- globals={"a": [1, 2, 3]},
288
- ),
289
- Case(
290
- description="negative array index out of bounds",
291
- template="{{ a[-4] }}",
292
- expect="",
293
- globals={"a": [1, 2, 3]},
294
- ),
295
- ]
@@ -1,63 +0,0 @@
1
- """Golden tests cases for testing liquid's built-in `plus` filter."""
2
-
3
- from liquid.golden.case import Case
4
-
5
- cases = [
6
- Case(
7
- description="integer value and integer arg",
8
- template=r"{{ 10 | plus: 2 }}",
9
- expect="12",
10
- ),
11
- Case(
12
- description="integer value and float arg",
13
- template=r"{{ 10 | plus: 2.0 }}",
14
- expect="12.0",
15
- ),
16
- Case(
17
- description="float value and float arg",
18
- template=r"{{ 10.1 | plus: 2.2 }}",
19
- expect="12.3",
20
- ),
21
- Case(
22
- description="string value and string arg",
23
- template=r'{{ "10.1" | plus: "2.2" }}',
24
- expect="12.3",
25
- ),
26
- Case(
27
- description="string not a number",
28
- template=r'{{ "foo" | plus: "2.0" }}',
29
- expect="2.0",
30
- ),
31
- Case(
32
- description="arg string not a number",
33
- template=r'{{ "10" | plus: "foo" }}',
34
- expect="10",
35
- ),
36
- Case(
37
- description="too many args",
38
- template=r"{{ 5 | plus: 1, '5' }}",
39
- expect="",
40
- error=True,
41
- ),
42
- Case(
43
- description="not a string, int or float",
44
- template=r"{{ a | plus: 1 }}",
45
- expect="1",
46
- globals={"a": {}},
47
- ),
48
- Case(
49
- description="undefined left value",
50
- template=r"{{ nosuchthing | plus: 2 }}",
51
- expect="2",
52
- ),
53
- Case(
54
- description="undefined argument",
55
- template=r"{{ 10 | plus: nosuchthing }}",
56
- expect="10",
57
- ),
58
- Case(
59
- description="integer value and negative integer arg",
60
- template=r"{{ 10 | plus: -2 }}",
61
- expect="8",
62
- ),
63
- ]
@@ -1,43 +0,0 @@
1
- """Golden tests cases for testing liquid's built-in `prepend` filter."""
2
-
3
- from liquid.golden.case import Case
4
-
5
- cases = [
6
- Case(
7
- description="concat",
8
- template=r'{{ "hello" | prepend: "there" }}',
9
- expect="therehello",
10
- ),
11
- Case(
12
- description="not a string",
13
- template=r"{{ 5 | prepend: 'there' }}",
14
- expect="there5",
15
- ),
16
- Case(
17
- description="argument not a string",
18
- template=r'{{ "hello" | prepend: 5 }}',
19
- expect="5hello",
20
- ),
21
- Case(
22
- description="missing argument",
23
- template=r'{{ "hello" | prepend }}',
24
- expect="",
25
- error=True,
26
- ),
27
- Case(
28
- description="too many arguments",
29
- template=r'{{ "hello" | prepend: "how", "are", "you" }}',
30
- expect="",
31
- error=True,
32
- ),
33
- Case(
34
- description="undefined left value",
35
- template=r'{{ nosuchthing | prepend: "hi" }}',
36
- expect="hi",
37
- ),
38
- Case(
39
- description="undefined argument",
40
- template=r'{{ "hi" | prepend: nosuchthing }}',
41
- expect="hi",
42
- ),
43
- ]
@@ -1,79 +0,0 @@
1
- """Golden tests cases for testing range objects."""
2
-
3
- from liquid.golden.case import Case
4
-
5
- cases = [
6
- Case(
7
- description="start is not a number",
8
- template=r"{{ (start..end) | join: '#' }}",
9
- globals={"start": "foo", "end": 5},
10
- expect="0#1#2#3#4#5",
11
- ),
12
- Case(
13
- description="end is not a number",
14
- template=r"{{ (start..end) | join: '#' }}",
15
- globals={"start": "1", "end": "foo"},
16
- expect="",
17
- ),
18
- Case(
19
- description="end is less than start",
20
- template=r"{{ (start..end) | join: '#' }}",
21
- globals={"start": 5, "end": 1},
22
- expect="",
23
- ),
24
- Case(
25
- description="start is negative",
26
- template=r"{{ (start..end) | join: '#' }}",
27
- globals={"start": -5, "end": 1},
28
- expect="-5#-4#-3#-2#-1#0#1",
29
- ),
30
- Case(
31
- description="start and end are negative",
32
- template=r"{{ (start..end) | join: '#' }}",
33
- globals={"start": -5, "end": -2},
34
- expect="-5#-4#-3#-2",
35
- ),
36
- Case(
37
- description="integer literals",
38
- template=r"{{ (1..5) | join: '#' }}",
39
- globals={},
40
- expect="1#2#3#4#5",
41
- ),
42
- Case(
43
- description="whitespace before start",
44
- template="{{ ( \n\t1..5) | join: '#' }}",
45
- globals={},
46
- expect="1#2#3#4#5",
47
- ),
48
- Case(
49
- description="whitespace after stop",
50
- template="{{ (1..5 \n\t) | join: '#' }}",
51
- globals={},
52
- expect="1#2#3#4#5",
53
- ),
54
- Case(
55
- description="whitespace before dots",
56
- template="{{ (1 \n\t..5) | join: '#' }}",
57
- globals={},
58
- expect="1#2#3#4#5",
59
- ),
60
- Case(
61
- description="whitespace after dots",
62
- template="{{ (1.. \n\t5) | join: '#' }}",
63
- globals={},
64
- expect="1#2#3#4#5",
65
- ),
66
- Case(
67
- description="whitespace before and after dots",
68
- template="{{ (1 .. 5) | join: '#' }}",
69
- globals={},
70
- expect="1#2#3#4#5",
71
- ),
72
- Case(
73
- description="whitespace before and after dots, for loop",
74
- template=r"{% for x in (1 .. 5) %}{{ x }},{% endfor %}",
75
- globals={},
76
- expect="1,2,3,4,5,",
77
- strict=True,
78
- ),
79
- ]
liquid/golden/raw_tag.py DELETED
@@ -1,31 +0,0 @@
1
- """Golden tests cases for testing liquid's `raw` tag."""
2
-
3
- from liquid.golden.case import Case
4
-
5
- cases = [
6
- Case(
7
- description="literal",
8
- template=r"{% raw %}foo{% endraw %}",
9
- expect="foo",
10
- ),
11
- Case(
12
- description="statement",
13
- template=r"{% raw %}{{ foo }}{% endraw %}",
14
- expect=r"{{ foo }}",
15
- ),
16
- Case(
17
- description="tag",
18
- template=r"{% raw %}{% assign x = 1 %}{% endraw %}",
19
- expect=r"{% assign x = 1 %}",
20
- ),
21
- Case(
22
- description="partial tag",
23
- template=r"{% raw %} %} {% }} {{ {% endraw %}",
24
- expect=r" %} {% }} {{ ",
25
- ),
26
- Case(
27
- description="continue after raw",
28
- template=r"{% raw %} {% some raw content %} {% endraw %}a literal",
29
- expect=r" {% some raw content %} a literal",
30
- ),
31
- ]