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,196 +0,0 @@
1
- """Golden tests cases for testing liquid's `include` 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"{% include 'product-hero' %}",
10
- expect="foo\n- sports\n- garden\n",
11
- globals={"product": {"title": "foo", "tags": ["sports", "garden"]}},
12
- partials={
13
- "product-hero": (
14
- r"{{ product.title }}"
15
- "\n"
16
- r"{% for tag in product.tags %}"
17
- r"- {{ tag }}"
18
- "\n"
19
- r"{% endfor %}"
20
- ),
21
- },
22
- ),
23
- Case(
24
- description="name from identifier",
25
- template=r"{% include snippet %}",
26
- expect="foo\n- sports\n- garden\n",
27
- globals={
28
- "snippet": "product-hero",
29
- "product": {"title": "foo", "tags": ["sports", "garden"]},
30
- },
31
- partials={
32
- "product-hero": (
33
- r"{{ product.title }}"
34
- "\n"
35
- r"{% for tag in product.tags %}"
36
- r"- {{ tag }}"
37
- "\n"
38
- r"{% endfor %}"
39
- ),
40
- },
41
- ),
42
- Case(
43
- description="bound variable",
44
- template=r"{% include 'product-title' with collection.products[1] %}",
45
- expect="car",
46
- globals={
47
- "collection": {
48
- "products": [{"title": "bike"}, {"title": "car"}],
49
- }
50
- },
51
- partials={
52
- "product-title": r"{{ product-title.title }}",
53
- },
54
- ),
55
- Case(
56
- description="bound variable does not exist",
57
- template=r"{% include 'product-title' with no.such.thing %}",
58
- expect="",
59
- partials={
60
- "product-title": r"{{ product-title.title }}",
61
- },
62
- ),
63
- Case(
64
- description="bound array variable",
65
- template=r"{% include 'prod' for collection.products %}",
66
- expect="bikecar",
67
- globals={
68
- "collection": {
69
- "products": [{"title": "bike"}, {"title": "car"}],
70
- }
71
- },
72
- partials={"prod": r"{{ prod.title }}"},
73
- ),
74
- Case(
75
- description="bound variable with alias",
76
- template=(
77
- r"{% include 'product-alias' with collection.products[1] as product %}"
78
- ),
79
- expect="car",
80
- globals={
81
- "collection": {
82
- "products": [{"title": "bike"}, {"title": "car"}],
83
- }
84
- },
85
- partials={"product-alias": r"{{ product.title }}"},
86
- ),
87
- Case(
88
- description="some keyword arguments",
89
- template=r"{% include 'product-args', foo: 'hello', bar: 'there' %}",
90
- expect="hello there",
91
- partials={"product-args": r"{{ foo }} {{ bar }}"},
92
- ),
93
- Case(
94
- description="some keyword arguments without leading comma",
95
- template=r"{% include 'product-args' foo: 'hello', bar: 'there' %}",
96
- expect="hello there",
97
- partials={"product-args": r"{{ foo }} {{ bar }}"},
98
- ),
99
- Case(
100
- description="some keyword arguments with float literals",
101
- template=r"{% include 'product-args' foo: 1.1, bar: 'there' %}",
102
- expect="1.1 there",
103
- partials={"product-args": r"{{ foo }} {{ bar }}"},
104
- ),
105
- Case(
106
- description="some keyword arguments with range literal",
107
- template=r"{% include 'product-args' foo: (1..3), bar: 'there' %}",
108
- expect="1#2#3 there",
109
- partials={"product-args": r"{{ foo | join: '#' }} {{ bar }}"},
110
- ),
111
- Case(
112
- description="template drop",
113
- template=r"{% include 'some/template-attrs.alt.txt' %}",
114
- expect="template-attrs.alt some template-attrs alt",
115
- partials={"some/template-attrs.alt.txt": TEMPLATE_DROP_ATTRS},
116
- standard=False,
117
- ),
118
- Case(
119
- description="template drop no parent",
120
- template=r"{% include 'template-attrs.alt.txt' %}",
121
- expect="template-attrs.alt template-attrs alt",
122
- partials={"template-attrs.alt.txt": TEMPLATE_DROP_ATTRS},
123
- standard=False,
124
- ),
125
- Case(
126
- description="template drop no suffix",
127
- template=r"{% include 'some/template-attrs.txt' %}",
128
- expect="template-attrs some template-attrs ",
129
- partials={"some/template-attrs.txt": TEMPLATE_DROP_ATTRS},
130
- standard=False,
131
- ),
132
- Case(
133
- description="template drop no suffix or extension",
134
- template=r"{% include 'some/template-attrs' %}",
135
- expect="template-attrs some template-attrs ",
136
- partials={"some/template-attrs": TEMPLATE_DROP_ATTRS},
137
- standard=False,
138
- ),
139
- Case(
140
- description="use globals from outer scope",
141
- template=r"{% include 'outer-scope' %}",
142
- expect="Hello, Holly",
143
- globals={"customer": {"first_name": "Holly"}},
144
- partials={"outer-scope": r"Hello, {{ customer.first_name }}"},
145
- ),
146
- Case(
147
- description="assign persists in outer scope",
148
- template=r"{% include 'assign-outer-scope' %} {{ last_name }}",
149
- expect="Hello, Holly Smith",
150
- globals={"customer": {"first_name": "Holly"}},
151
- partials={
152
- "assign-outer-scope": (
153
- r"Hello, {{ customer.first_name }}{% assign last_name = 'Smith' %}"
154
- ),
155
- },
156
- ),
157
- Case(
158
- description="counter from outer scope",
159
- template=(
160
- r"{% increment foo %} "
161
- r"{% include 'increment-outer-scope' %} "
162
- r"{% increment foo %}"
163
- ),
164
- expect="0 1 2",
165
- partials={"increment-outer-scope": r"{% increment foo %}"},
166
- ),
167
- Case(
168
- description="break from include",
169
- template=r"{% for tag in product.tags %}{% include 'tag-break' %}{% endfor %}",
170
- expect="SPORTS",
171
- globals={"product": {"tags": ["sports", "garden"]}},
172
- partials={"tag-break": r"{{ tag | upcase }}{% break %}"},
173
- ),
174
- Case(
175
- description="break from nested include",
176
- template=r"{% for tag in product.tags %}{% include 'tag' %}{% endfor %}",
177
- expect="SPORTS break!",
178
- globals={"product": {"tags": ["sports", "garden"]}},
179
- partials={
180
- "tag": r"{{ tag | upcase }}{% include 'break' %}",
181
- "break": r" break!{% break %}",
182
- },
183
- ),
184
- Case(
185
- description="keyword arguments go out of scope",
186
- template=r"{% include 'product-args', foo: 'hello', bar: 'there' %}{{ foo }}",
187
- expect="hello there",
188
- partials={"product-args": r"{{ foo }} {{ bar }}"},
189
- ),
190
- Case(
191
- description="assign to a keyword argument",
192
- template=r"{% include 'product-args', foo: 'hello' %} {{ foo }}",
193
- expect="hello hello goodbye",
194
- partials={"product-args": r"{{ foo }}{% assign foo = 'goodbye' %} {{ foo }}"},
195
- ),
196
- ]
@@ -1,48 +0,0 @@
1
- """Golden tests cases for testing liquid's `increment` tag."""
2
-
3
- from liquid.golden.case import Case
4
-
5
- cases = [
6
- Case(
7
- description="named counter",
8
- template=r"{% increment foo %} {% increment foo %} {% increment foo %}",
9
- expect="0 1 2",
10
- ),
11
- Case(
12
- description="incrementing counter renders before incrementing",
13
- template=r"{% increment foo %} {{ foo }}",
14
- expect="0 1",
15
- ),
16
- Case(
17
- description="multiple named counters",
18
- template=(
19
- r"{% increment foo %} "
20
- r"{% increment bar %} "
21
- r"{% increment foo %} "
22
- r"{% increment bar %}"
23
- ),
24
- expect="0 0 1 1",
25
- ),
26
- Case(
27
- description="assign and increment",
28
- template=(
29
- r"{% assign foo = 5 %}"
30
- r"{{ foo }} "
31
- r"{% increment foo %} "
32
- r"{% increment foo %} "
33
- r"{{ foo }}"
34
- ),
35
- expect="5 0 1 5",
36
- ),
37
- Case(
38
- description="named counters are in scope for subsequent expressions",
39
- template=(
40
- r"{% increment foo %} "
41
- r"{% increment foo %} "
42
- r"{% if foo > 0 %}"
43
- r"{{ foo }}"
44
- r"{% endif %}"
45
- ),
46
- expect="0 1 2",
47
- ),
48
- ]
@@ -1,127 +0,0 @@
1
- """Golden tests cases for testing liquid's `#` tag."""
2
-
3
- from liquid.golden.case import Case
4
-
5
- cases = [
6
- Case(
7
- description="with whitespace control and padding",
8
- template=r"{%- # some comment -%}",
9
- expect="",
10
- ),
11
- Case(
12
- description="with whitespace control no padding",
13
- template=r"{%-# some comment -%}",
14
- expect="",
15
- ),
16
- Case(
17
- description="no whitespace control with padding",
18
- template=r"{% # some comment %}",
19
- expect="",
20
- ),
21
- Case(
22
- description="no whitespace control no padding",
23
- template=r"{%# some comment %}",
24
- expect="",
25
- ),
26
- Case(
27
- description="no padding after the hash",
28
- template=r"{%#some comment %}",
29
- expect="",
30
- ),
31
- Case(
32
- description="empty",
33
- template=r"{%#%}",
34
- expect="",
35
- ),
36
- Case(
37
- description="liquid tag",
38
- template="\n".join(
39
- [
40
- r"{% liquid ",
41
- r" # first comment line",
42
- r" # second comment line",
43
- r"",
44
- r" # another comment line",
45
- r" echo 'Hello '",
46
- r"",
47
- r" # more comments",
48
- r" echo 'goodbye'",
49
- r"-%}",
50
- ]
51
- ),
52
- expect="Hello goodbye",
53
- ),
54
- Case(
55
- description="multiple lines",
56
- template="\n".join(
57
- [
58
- "{%-",
59
- " # spread inline comments",
60
- " # over multiple lines",
61
- "-%}",
62
- ]
63
- ),
64
- expect="",
65
- ),
66
- Case(
67
- description="lots of hashes in a liquid tag",
68
- template="\n".join(
69
- [
70
- r"{% liquid",
71
- r" ##########################",
72
- r" # spread inline comments #",
73
- r" ##########################",
74
- r"-%}",
75
- ]
76
- ),
77
- expect="",
78
- ),
79
- Case(
80
- description="enforce leading hash",
81
- template="\n".join(
82
- [
83
- "{%-",
84
- " # spread inline comments",
85
- " over multiple lines",
86
- "-%}",
87
- ]
88
- ),
89
- expect="",
90
- error=True,
91
- ),
92
- Case(
93
- description="can't comment tags",
94
- template="{%- # {% echo 'hello world' %} -%}",
95
- expect=" -%}",
96
- ),
97
- Case(
98
- description="comment with single quote",
99
- template=r"{%# some 'comment %}",
100
- expect="",
101
- ),
102
- Case(
103
- description="comment with single quoted string",
104
- template=r"{%# some 'comment' %}",
105
- expect="",
106
- ),
107
- Case(
108
- description="comment with double quote",
109
- template='{%# some "comment %}',
110
- expect="",
111
- ),
112
- Case(
113
- description="comment with double quoted string",
114
- template='{%# some "comment" %}',
115
- expect="",
116
- ),
117
- Case(
118
- description="comment with u2018",
119
- template="{%# some ‘comment %}",
120
- expect="",
121
- ),
122
- Case(
123
- description="comment with u201C",
124
- template="{%# some “comment %}",
125
- expect="",
126
- ),
127
- ]
@@ -1,69 +0,0 @@
1
- """Golden tests cases for testing liquid's built-in `join` filter."""
2
-
3
- from liquid.golden.case import Case
4
-
5
- cases = [
6
- Case(
7
- description="range literal join filter left value",
8
- template=r"{{ (1..3) | join: '#' }}",
9
- expect="1#2#3",
10
- ),
11
- Case(
12
- description="joining a string is a noop",
13
- template=r"{{ 'a,b' | join: '#' }}",
14
- expect="a,b",
15
- ),
16
- Case(
17
- description="joining an int is a noop",
18
- template=r"{{ 123 | join: '#' }}",
19
- expect="123",
20
- ),
21
- Case(
22
- description="join an array of strings",
23
- template=r"{{ arr | join: '#' }}",
24
- expect="a#b",
25
- globals={"arr": ["a", "b"]},
26
- ),
27
- Case(
28
- description="join an array of integers",
29
- template=r"{{ arr | join: '#' }}",
30
- expect="1#2",
31
- globals={"arr": [1, 2]},
32
- ),
33
- Case(
34
- description="missing argument defaults to a space",
35
- template=r"{{ arr | join }}",
36
- expect="a b",
37
- globals={"arr": ["a", "b"]},
38
- ),
39
- Case(
40
- description="argument is not a string",
41
- template=r"{{ arr | join: 5 }}",
42
- expect="a5b",
43
- globals={"arr": ["a", "b"]},
44
- ),
45
- Case(
46
- description="left value contains non string",
47
- template=r"{{ arr | join: '#' }}",
48
- expect="a#b#1",
49
- globals={"arr": ["a", "b", 1]},
50
- ),
51
- Case(
52
- description="undefined left value",
53
- template=r"{{ nosuchthing | join: '#' }}",
54
- expect="",
55
- ),
56
- Case(
57
- description="undefined argument",
58
- template=r"{{ arr | join: nosuchthing }}",
59
- expect="ab",
60
- globals={"arr": ["a", "b"]},
61
- ),
62
- Case(
63
- description="too many arguments",
64
- template=r"{{ arr | join: '#', 42 }}",
65
- expect="",
66
- globals={"arr": ["a", "b"]},
67
- error=True,
68
- ),
69
- ]
@@ -1,51 +0,0 @@
1
- """Golden tests cases for testing liquid's built-in `first` filter."""
2
-
3
- from liquid.golden.case import Case
4
-
5
- cases = [
6
- Case(
7
- description="range literal last filter left value",
8
- template=r"{{ (1..3) | last }}",
9
- expect="3",
10
- ),
11
- Case(
12
- description="array of strings",
13
- template=r"{{ arr | last }}",
14
- expect="b",
15
- globals={"arr": ["a", "b"]},
16
- ),
17
- Case(
18
- description="array of things",
19
- template=r"{{ arr | last }}",
20
- expect="{}",
21
- globals={"arr": ["a", "b", 1, [], {}]},
22
- ),
23
- Case(
24
- description="empty array",
25
- template=r"{{ arr | last }}",
26
- expect="",
27
- globals={"arr": []},
28
- ),
29
- Case(
30
- description="left value not an array",
31
- template=r"{{ arr | last }}",
32
- expect="",
33
- globals={"arr": 12},
34
- ),
35
- Case(
36
- description="left value is undefined",
37
- template=r"{{ nosuchthing | last }}",
38
- expect="",
39
- ),
40
- Case(
41
- description="last of a string",
42
- template=r"{{ 'hello' | last }}",
43
- expect="",
44
- ),
45
- Case(
46
- description="last of a hash",
47
- template=r"{{ a | last }}",
48
- expect="",
49
- globals={"a": {"b": 1, "c": 2}},
50
- ),
51
- ]