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
liquid/golden/doc_tag.py DELETED
@@ -1,61 +0,0 @@
1
- """Golden tests cases for testing liquid's `doc` tag."""
2
-
3
- from liquid.golden.case import Case
4
-
5
- cases = [
6
- Case(
7
- description="don't render docs",
8
- template=r"{% doc %}don't render me{% enddoc %}",
9
- expect="",
10
- ),
11
- Case(
12
- description="doc arguments is an error",
13
- template=r"{% doc hello %}don't render me{% enddoc %}",
14
- expect="",
15
- error=True,
16
- ),
17
- Case(
18
- description="doc tag block must be closed",
19
- template=r"{% doc %}don't render me",
20
- expect="",
21
- error=True,
22
- ),
23
- Case(
24
- description="doc text is not parsed",
25
- template=(
26
- r"{% doc %}"
27
- r" {% if true %}"
28
- r" {% if ... %}"
29
- r" {%- for ? -%}"
30
- r" {% while true %}"
31
- r" {%"
32
- r" unless if"
33
- r" %}"
34
- r" {% endcase %}"
35
- r" {% raw %}"
36
- r"{% enddoc %}"
37
- ),
38
- expect="",
39
- ),
40
- Case(
41
- description="nested docs are not allowed",
42
- template=r"{% doc hello %}Hello{% doc %}{% enddoc %}",
43
- expect="",
44
- error=True,
45
- ),
46
- Case(
47
- description="docs containing unclosed tags are ok",
48
- template=r"{% doc %}{% assign x = y {% enddoc %}",
49
- expect="",
50
- ),
51
- Case(
52
- description="docs containing unclosed output are ok",
53
- template=r"{% doc %}{{ foo {% enddoc %}",
54
- expect="",
55
- ),
56
- Case(
57
- description="whitespace control",
58
- template="foo\n {%- doc %}I'm a doc comment{% enddoc -%} \tbar",
59
- expect="foobar",
60
- ),
61
- ]
@@ -1,27 +0,0 @@
1
- """Golden tests cases for testing liquid's built-in `downcase` filter."""
2
-
3
- from liquid.golden.case import Case
4
-
5
- cases = [
6
- Case(
7
- description="make lower case",
8
- template=r'{{ "HELLO" | downcase }}',
9
- expect="hello",
10
- ),
11
- Case(
12
- description="not a string",
13
- template=r"{{ 5 | downcase }}",
14
- expect="5",
15
- ),
16
- Case(
17
- description="unexpected argument",
18
- template=r'{{ "HELLO" | downcase: 5 }}',
19
- expect="",
20
- error=True,
21
- ),
22
- Case(
23
- description="undefined left value",
24
- template=r"{{ nosuchthing | downcase }}",
25
- expect="",
26
- ),
27
- ]
liquid/golden/echo_tag.py DELETED
@@ -1,116 +0,0 @@
1
- """Golden tests cases for testing liquid's `echo` tag."""
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"{% echo 'hello' %}",
11
- expect="hello",
12
- ),
13
- Case(
14
- description="render an integer literal",
15
- template=r"{% echo 123 %}",
16
- expect="123",
17
- ),
18
- Case(
19
- description="render a float literal",
20
- template=r"{% echo 1.23 %}",
21
- expect="1.23",
22
- ),
23
- Case(
24
- description="render a variable from the global namespace",
25
- template=r"{% echo product.title %}",
26
- expect="foo",
27
- globals={"product": {"title": "foo"}},
28
- ),
29
- Case(
30
- description="render a variable from the local namespace",
31
- template=r"{% assign name = 'Brian' %}{% echo name %}",
32
- expect="Brian",
33
- ),
34
- Case(
35
- description="render an undefined variable",
36
- template=r"{% echo age %}",
37
- expect="",
38
- ),
39
- Case(
40
- description="render an undefined property",
41
- template=r"{% echo product.age %}",
42
- expect="",
43
- globals={"product": {"title": "foo"}},
44
- ),
45
- Case(
46
- description="access an array item by index",
47
- template=r"{% echo product.tags[1] %}",
48
- expect="garden",
49
- globals={"product": {"tags": ["sports", "garden"]}},
50
- ),
51
- Case(
52
- description="access an array item by negative index",
53
- template=r"{% echo product.tags[-2] %}",
54
- expect="sports",
55
- globals={"product": {"tags": ["sports", "garden"]}},
56
- ),
57
- Case(
58
- description="access array item by index stored in a local variable",
59
- template=r"{% assign i = 1 %}{% echo product.tags[i] %}",
60
- expect="garden",
61
- globals={"product": {"tags": ["sports", "garden"]}},
62
- ),
63
- Case(
64
- description="render a global identifier with a filter",
65
- template=r"{% echo product.title | upcase %}",
66
- expect="FOO",
67
- globals={"product": {"title": "foo"}},
68
- ),
69
- Case(
70
- description="dump an array from the global context",
71
- template=r"{% echo product.tags %}",
72
- expect="sportsgarden",
73
- globals={"product": {"tags": ["sports", "garden"]}},
74
- ),
75
- Case(
76
- description="assign a variable the value of an existing variable",
77
- template=(
78
- r"{% capture some %}hello{% endcapture %}"
79
- r"{% assign other = some %}"
80
- r"{% assign some = 'foo' %}"
81
- r"{% echo some %}-{% echo other %}"
82
- ),
83
- expect="foo-hello",
84
- ),
85
- Case(
86
- description="traverse variables with bracketed identifiers",
87
- template=r"{% echo site.data.menu[include.menu][include.locale] %}",
88
- expect="it works!",
89
- globals={
90
- "site": {"data": {"menu": {"foo": {"bar": "it works!"}}}},
91
- "include": {"menu": "foo", "locale": "bar"},
92
- },
93
- ),
94
- Case(
95
- description="render the special built in variable 'now'",
96
- template=r"{% echo now | date: '%d/%m/%Y' %}",
97
- expect=datetime.datetime.now().strftime(r"%d/%m/%Y"),
98
- standard=False,
99
- ),
100
- Case(
101
- description="render the special built in variable 'today'",
102
- template=r"{% echo today | date: '%d/%m/%Y' %}",
103
- expect=datetime.date.today().strftime(r"%d/%m/%Y"),
104
- standard=False,
105
- ),
106
- Case(
107
- description="access an undefined variable by index",
108
- template=r"{% echo nosuchthing[0] %}",
109
- expect="",
110
- ),
111
- Case(
112
- description="nothing to echo",
113
- template=r"{% echo %}",
114
- expect="",
115
- ),
116
- ]
@@ -1,27 +0,0 @@
1
- """Golden tests cases for testing liquid's built-in `escape` filter."""
2
-
3
- from liquid.golden.case import Case
4
-
5
- cases = [
6
- Case(
7
- description="make HTML-safe",
8
- template=r'{{ "<p>test</p>" | escape }}',
9
- expect="&lt;p&gt;test&lt;/p&gt;",
10
- ),
11
- Case(
12
- description="not a string",
13
- template=r"{{ 5 | escape }}",
14
- expect="5",
15
- ),
16
- Case(
17
- description="unexpected argument",
18
- template=r'{{ "HELLO" | escape: 5 }}',
19
- expect="",
20
- error=True,
21
- ),
22
- Case(
23
- description="undefined left value",
24
- template=r"{{ nosuchthing | escape }}",
25
- expect="",
26
- ),
27
- ]
@@ -1,32 +0,0 @@
1
- """Golden tests cases for testing liquid's built-in `escape_once` filter."""
2
-
3
- from liquid.golden.case import Case
4
-
5
- cases = [
6
- Case(
7
- description="make HTML-safe",
8
- template=r'{{ "&lt;p&gt;test&lt;/p&gt;" | escape_once }}',
9
- expect="&lt;p&gt;test&lt;/p&gt;",
10
- ),
11
- Case(
12
- description="make HTML-safe from mixed safe and markup.",
13
- template=r'{{ "&lt;p&gt;test&lt;/p&gt;<p>test</p>" | escape_once }}',
14
- expect="&lt;p&gt;test&lt;/p&gt;&lt;p&gt;test&lt;/p&gt;",
15
- ),
16
- Case(
17
- description="not a string",
18
- template=r"{{ 5 | escape_once }}",
19
- expect="5",
20
- ),
21
- Case(
22
- description="unexpected argument",
23
- template=r'{{ "HELLO" | escape_once: 5 }}',
24
- expect="",
25
- error=True,
26
- ),
27
- Case(
28
- description="undefined left value",
29
- template=r"{{ nosuchthing | escape_once }}",
30
- expect="",
31
- ),
32
- ]
@@ -1,90 +0,0 @@
1
- """Test cases for the standard `find` filter."""
2
-
3
- from liquid.golden.case import Case
4
-
5
- cases = [
6
- Case(
7
- description="array of strings, default value",
8
- template=r"{{ a | find: 'z' }}",
9
- expect="z",
10
- globals={"a": ["x", "y", "z"]},
11
- ),
12
- Case(
13
- description="array of strings, substring match, default value",
14
- template=r"{{ a | find: 'oo' }}",
15
- expect="zoo",
16
- globals={"a": ["x", "y", "zoo"]},
17
- ),
18
- Case(
19
- description="array of strings, default value, no match",
20
- template=r"{{ a | find: 'foo' }}",
21
- expect="",
22
- globals={"a": ["x", "y", "zoo"]},
23
- ),
24
- # Case(
25
- # description="array of ints, default value",
26
- # template=r"{{ a | find: 2 }}",
27
- # expect="1",
28
- # globals={"a": [1, 2, 3]},
29
- # ),
30
- Case(
31
- description="mixed array, default value",
32
- template=r"{{ a | find: 'z' }}",
33
- expect="",
34
- globals={"a": ["x", None, "z", False, True]},
35
- ),
36
- Case(
37
- description="string input, default value, match",
38
- template=r"{{ a | find: 'z' }}",
39
- expect="zoo",
40
- globals={"a": "zoo"},
41
- ),
42
- Case(
43
- description="string input, string value, match",
44
- template=r"{{ a | find: 'z', 'z' }}",
45
- expect="zoo",
46
- globals={"a": "zoo"},
47
- ),
48
- Case(
49
- description="string input, string value, no match",
50
- template=r"{{ a | find: 'z', 'y' }}",
51
- expect="",
52
- globals={"a": "zoo"},
53
- ),
54
- Case(
55
- description="hash input, default value, match",
56
- template=r"{% assign b = a | find: 'z' %}{{ b.z }}",
57
- expect="42",
58
- globals={"a": {"z": 42}},
59
- ),
60
- Case(
61
- description="hash input, default value, no match",
62
- template=r"{% assign b = a | find: 'foo' %}{{ b }}",
63
- expect="",
64
- globals={"a": {"z": 42}},
65
- ),
66
- Case(
67
- description="hash input, int value, match",
68
- template=r"{% assign b = a | find: 'z', 42 %}{{ b.z }}",
69
- expect="42",
70
- globals={"a": {"z": 42}},
71
- ),
72
- Case(
73
- description="hash input, explicit nil, match",
74
- template=r"{% assign b = a | find: 'z', nil %}{{ b.z }}",
75
- expect="",
76
- globals={"a": {"z": None}},
77
- ),
78
- Case(
79
- description="array of hashes, int value, match",
80
- template=r"{% assign b = a | find: 'z', 42 %}{{ b.foo }}",
81
- expect="bar",
82
- globals={"a": [{"x": 99}, {"z": 42, "foo": "bar"}]},
83
- ),
84
- Case(
85
- description="array of hashes, with a nil",
86
- template=r"{% assign b = a | find: 'z', 42 %}{{ b.foo }}",
87
- expect="",
88
- globals={"a": [{"x": 99}, None, {"z": 42, "foo": "bar"}]},
89
- ),
90
- ]
@@ -1,96 +0,0 @@
1
- """Test cases for the standard `find_index` filter."""
2
-
3
- from liquid.golden.case import Case
4
-
5
- cases = [
6
- Case(
7
- description="array of strings, default value",
8
- template=r"{{ a | find_index: 'z' }}",
9
- expect="2",
10
- globals={"a": ["x", "y", "z"]},
11
- ),
12
- Case(
13
- description="array of strings, substring match, default value",
14
- template=r"{{ a | find_index: 'oo' }}",
15
- expect="2",
16
- globals={"a": ["x", "y", "zoo"]},
17
- ),
18
- Case(
19
- description="array of strings, default value, no match",
20
- template=r"{{ a | find_index: 'foo' }}",
21
- expect="",
22
- globals={"a": ["x", "y", "zoo"]},
23
- ),
24
- # Case(
25
- # description="array of ints, default value",
26
- # template=r"{{ a | find_index: 3 }}",
27
- # expect="0",
28
- # globals={"a": [1, 2, 3]},
29
- # ),
30
- Case(
31
- description="mixed array, default value",
32
- template=r"{{ a | find_index: 'z' }}",
33
- expect="",
34
- globals={"a": ["x", None, "z", False, True]},
35
- ),
36
- Case(
37
- description="string input, default value, match",
38
- template=r"{{ a | find_index: 'z' }}",
39
- expect="0",
40
- globals={"a": "zoo"},
41
- ),
42
- Case(
43
- description="string input, string value, match",
44
- template=r"{{ a | find_index: 'z', 'z' }}",
45
- expect="0",
46
- globals={"a": "zoo"},
47
- ),
48
- Case(
49
- description="string input, string value, no match",
50
- template=r"{{ a | find_index: 'z', 'y' }}",
51
- expect="",
52
- globals={"a": "zoo"},
53
- ),
54
- Case(
55
- description="hash input, default value, match",
56
- template=r"{{ a | find_index: 'z' }}",
57
- expect="0",
58
- globals={"a": {"z": 42}},
59
- ),
60
- Case(
61
- description="hash input, default value, no match",
62
- template=r"{{ a | find_index: 'foo' }}",
63
- expect="",
64
- globals={"a": {"z": 42}},
65
- ),
66
- Case(
67
- description="hash input, int value, match",
68
- template=r"{{ a | find_index: 'z', 42 }}",
69
- expect="0",
70
- globals={"a": {"z": 42}},
71
- ),
72
- Case(
73
- description="hash input, explicit nil, match",
74
- template=r"{{ a | find_index: 'z', nil }}",
75
- expect="",
76
- globals={"a": {"z": None}},
77
- ),
78
- Case(
79
- description="array of hashes, explicit nil, match",
80
- template=r"{{ a | find_index: 'z', nil }}",
81
- expect="",
82
- globals={"a": ["foo", "bar", {"z": None}]},
83
- ),
84
- Case(
85
- description="array of hashes, int value, match",
86
- template=r"{{ a | find_index: 'z', 42 }}",
87
- expect="1",
88
- globals={"a": [{"x": 99}, {"z": 42, "foo": "bar"}]},
89
- ),
90
- Case(
91
- description="array of hashes, with a nil",
92
- template=r"{% assign b = a | find_index: 'z', 42 %}{{ b.foo }}",
93
- expect="",
94
- globals={"a": [{"x": 99}, None, {"z": 42, "foo": "bar"}]},
95
- ),
96
- ]
@@ -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 first filter left value",
8
- template=r"{{ (1..3) | first }}",
9
- expect="1",
10
- ),
11
- Case(
12
- description="array of strings",
13
- template=r"{{ arr | first }}",
14
- expect="a",
15
- globals={"arr": ["a", "b"]},
16
- ),
17
- Case(
18
- description="array of things",
19
- template=r"{{ arr | first }}",
20
- expect="a",
21
- globals={"arr": ["a", "b", 1, [], {}]},
22
- ),
23
- Case(
24
- description="empty left value",
25
- template=r"{{ arr | first }}",
26
- expect="",
27
- globals={"arr": []},
28
- ),
29
- Case(
30
- description="left value is not an array",
31
- template=r"{{ arr | first }}",
32
- expect="",
33
- globals={"arr": 12},
34
- ),
35
- Case(
36
- description="left value is undefined",
37
- template=r"{{ nosuchthing | first }}",
38
- expect="",
39
- ),
40
- Case(
41
- description="first of a string",
42
- template=r"{{ 'hello' | first }}",
43
- expect="",
44
- ),
45
- Case(
46
- description="first of a hash",
47
- template=r"{% assign x = a | first %}({{ x[0] }},{{ x[1] }})",
48
- expect="(b,1)",
49
- globals={"a": {"b": 1, "c": 2}},
50
- ),
51
- ]
@@ -1,63 +0,0 @@
1
- """Golden tests cases for testing liquid's built-in `ceil` filter."""
2
-
3
- from liquid.golden.case import Case
4
-
5
- cases = [
6
- Case(
7
- description="positive integer",
8
- template=r"{{ 5 | floor }}",
9
- expect="5",
10
- ),
11
- Case(
12
- description="negative integer",
13
- template=r"{{ -5 | floor }}",
14
- expect="-5",
15
- ),
16
- Case(
17
- description="positive float",
18
- template=r"{{ 5.4 | floor }}",
19
- expect="5",
20
- ),
21
- Case(
22
- description="negative float",
23
- template=r"{{ -5.4 | floor }}",
24
- expect="-6",
25
- ),
26
- Case(
27
- description="zero",
28
- template=r"{{ 0 | floor }}",
29
- expect="0",
30
- ),
31
- Case(
32
- description="positive string float",
33
- template=r'{{ "5.1" | floor }}',
34
- expect="5",
35
- ),
36
- Case(
37
- description="negative string float",
38
- template=r'{{ "-5.1" | floor }}',
39
- expect="-6",
40
- ),
41
- Case(
42
- description="unexpected argument",
43
- template=r"{{ -3.1 | floor: 1 }}",
44
- expect="",
45
- error=True,
46
- ),
47
- Case(
48
- description="string not a number",
49
- template=r'{{ "hello" | floor }}',
50
- expect="0",
51
- ),
52
- Case(
53
- description="not a string, int or float",
54
- template=r"{{ a | floor }}",
55
- expect="0",
56
- globals={"a": {}},
57
- ),
58
- Case(
59
- description="undefined left value",
60
- template=r"{{ nosuchthing | floor }}",
61
- expect="0",
62
- ),
63
- ]