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,59 +0,0 @@
1
- """Golden tests cases for testing liquid's built-in `replace_first` 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_first: "my", "your" }}'
11
- ),
12
- expect="Take your protein pills and put my helmet on",
13
- ),
14
- Case(
15
- description="not a string",
16
- template=r"{{ 5 | replace_first: 'rain', 'foo' }}",
17
- expect="5",
18
- ),
19
- Case(
20
- description="argument not a string",
21
- template=r'{{ "hello5" | replace_first: 5, "your" }}',
22
- expect="helloyour",
23
- ),
24
- Case(
25
- description="missing argument",
26
- template=r'{{ "hello" | replace_first: "ll" }}',
27
- expect="heo",
28
- ),
29
- Case(
30
- description="missing arguments",
31
- template=r'{{ "hello" | replace_first }}',
32
- expect="",
33
- error=True,
34
- ),
35
- Case(
36
- description="too many arguments",
37
- template=r'{{ "hello" | replace_first: "how", "are", "you" }}',
38
- expect="",
39
- error=True,
40
- ),
41
- Case(
42
- description="undefined left value",
43
- template=r'{{ nosuchthing | replace_first: "my", "your" }}',
44
- expect="",
45
- ),
46
- Case(
47
- description="undefined first argument",
48
- template=r'{{ "Take my protein" | replace_first: nosuchthing, "#" }}',
49
- expect="#Take my protein",
50
- ),
51
- Case(
52
- description="undefined second argument",
53
- template=(
54
- r'{{ "Take my protein pills and put my helmet on" '
55
- r'| replace_first: "my", nosuchthing }}'
56
- ),
57
- expect="Take protein pills and put my helmet on",
58
- ),
59
- ]
@@ -1,60 +0,0 @@
1
- """Golden tests cases for testing liquid's built-in `replace_last` 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_last: "my", "your" }}'
11
- ),
12
- expect="Take my protein pills and put your helmet on",
13
- ),
14
- Case(
15
- description="not a string",
16
- template=r"{{ 5 | replace_last: 'rain', 'foo' }}",
17
- expect="5",
18
- ),
19
- Case(
20
- description="argument not a string",
21
- template=r'{{ "hello5" | replace_last: 5, "your" }}',
22
- expect="helloyour",
23
- ),
24
- Case(
25
- description="missing argument",
26
- template=r'{{ "hello" | replace_last: "ll" }}',
27
- expect="",
28
- error=True,
29
- ),
30
- Case(
31
- description="missing arguments",
32
- template=r'{{ "hello" | replace_last }}',
33
- expect="",
34
- error=True,
35
- ),
36
- Case(
37
- description="too many arguments",
38
- template=r'{{ "hello" | replace_last: "how", "are", "you" }}',
39
- expect="",
40
- error=True,
41
- ),
42
- Case(
43
- description="undefined left value",
44
- template=r'{{ nosuchthing | replace_last: "my", "your" }}',
45
- expect="",
46
- ),
47
- Case(
48
- description="undefined first argument",
49
- template=r'{{ "Take my protein" | replace_last: nosuchthing, "#" }}',
50
- expect="Take my protein#",
51
- ),
52
- Case(
53
- description="undefined second argument",
54
- template=(
55
- r'{{ "Take my protein pills and put my helmet on" '
56
- r'| replace_last: "my", nosuchthing }}'
57
- ),
58
- expect="Take my protein pills and put helmet on",
59
- ),
60
- ]
@@ -1,42 +0,0 @@
1
- """Golden tests cases for testing liquid's built-in `reverse` filter."""
2
-
3
- from liquid.golden.case import Case
4
-
5
- cases = [
6
- Case(
7
- description="array of strings",
8
- template=r"{{ a | reverse | join: '#' }}",
9
- expect="A#B#a#b",
10
- globals={"a": ["b", "a", "B", "A"]},
11
- ),
12
- Case(
13
- description="array of things",
14
- template=r"{{ a | reverse | join: '#' }}",
15
- expect=r"{}#1#b#a",
16
- globals={"a": ["a", "b", 1, [], {}]},
17
- ),
18
- Case(
19
- description="empty array",
20
- template=r"{{ a | reverse | join: '#' }}",
21
- expect="",
22
- globals={"a": []},
23
- ),
24
- Case(
25
- description="unexpected argument",
26
- template=r"{{ a | reverse: 0 | join: '#' }}",
27
- expect="",
28
- globals={"a": []},
29
- error=True,
30
- ),
31
- Case(
32
- description="left value not an array",
33
- template=r"{{ a | reverse | join: '#' }}",
34
- expect="123",
35
- globals={"a": 123},
36
- ),
37
- Case(
38
- description="left value is undefined",
39
- template=r"{{ nosuchthing | reverse | join: '#' }}",
40
- expect="",
41
- ),
42
- ]
@@ -1,87 +0,0 @@
1
- """Golden tests cases for testing liquid's built-in `round` filter."""
2
-
3
- from liquid.golden.case import Case
4
-
5
- cases = [
6
- Case(
7
- description="float round down",
8
- template=r"{{ 5.1 | round }}",
9
- expect="5",
10
- ),
11
- Case(
12
- description="float round up",
13
- template=r"{{ 5.6 | round }}",
14
- expect="6",
15
- ),
16
- Case(
17
- description="float as a string",
18
- template=r'{{ "5.6" | round }}',
19
- expect="6",
20
- ),
21
- Case(
22
- description="string argument",
23
- template=r'{{ 5.666 | round: "1" }}',
24
- expect="5.7",
25
- ),
26
- Case(
27
- description="decimal places",
28
- template=r'{{ "5.666666" | round: 2 }}',
29
- expect="5.67",
30
- ),
31
- Case(
32
- description="integer",
33
- template=r"{{ 5 | round }}",
34
- expect="5",
35
- ),
36
- Case(
37
- description="too many args",
38
- template=r"{{ 5 | round: 1, 2 }}",
39
- expect="",
40
- error=True,
41
- ),
42
- Case(
43
- description="undefined left value",
44
- template=r"{{ nosuchthing | round: 2 }}",
45
- expect="0",
46
- ),
47
- Case(
48
- description="undefined argument",
49
- template=r"{{ 5.666 | round: nosuchthing }}",
50
- expect="6",
51
- ),
52
- Case(
53
- description="argument is a string",
54
- template=r"{{ 5.666 | round: 'foo' }}",
55
- expect="6",
56
- ),
57
- Case(
58
- description="argument is a string representation of an integer",
59
- template=r"{{ 5.666 | round: '1' }}",
60
- expect="5.7",
61
- ),
62
- Case(
63
- description="argument is a string representation of zero",
64
- template=r"{{ 5.666 | round: '1' }}",
65
- expect="5.7",
66
- ),
67
- # Case(
68
- # description="argument is a string representation of a negative integer",
69
- # template=r"{{ 5.666 | round: '-1' }}",
70
- # expect="10",
71
- # ),
72
- Case(
73
- description="argument is a negative",
74
- template=r"{{ 5.666 | round: -2 }}",
75
- expect="0",
76
- ),
77
- Case(
78
- description="argument is a float",
79
- template=r"{{ 5.666 | round: 1.2 }}",
80
- expect="5.7",
81
- ),
82
- Case(
83
- description="argument is a zero",
84
- template=r"{{ 5.666 | round: 0 }}",
85
- expect="6",
86
- ),
87
- ]
@@ -1,37 +0,0 @@
1
- """Golden tests cases for testing liquid's built-in `rstrip` filter."""
2
-
3
- from liquid.golden.case import Case
4
-
5
- cases = [
6
- Case(
7
- description="left padded",
8
- template='{{ " \t\r\n hello" | rstrip }}',
9
- expect=" \t\r\n hello",
10
- ),
11
- Case(
12
- description="right padded",
13
- template='{{ "hello \t\r\n " | rstrip }}',
14
- expect="hello",
15
- ),
16
- Case(
17
- description="left and right padded",
18
- template='{{ " \t\r\n hello \t\r\n " | rstrip }}',
19
- expect=" \t\r\n hello",
20
- ),
21
- Case(
22
- description="not a string",
23
- template="{{ 5 | rstrip }}",
24
- expect="5",
25
- ),
26
- Case(
27
- description="unexpected argument",
28
- template='{{ "hello" | rstrip: 5 }}',
29
- expect="",
30
- error=True,
31
- ),
32
- Case(
33
- description="undefined left value",
34
- template="{{ nosuchthing | rstrip }}",
35
- expect="",
36
- ),
37
- ]
@@ -1,42 +0,0 @@
1
- """Golden tests cases for testing liquid's built-in `size` filter."""
2
-
3
- from liquid.golden.case import Case
4
-
5
- cases = [
6
- Case(
7
- description="size of an array",
8
- template=r"{{ a | size }}",
9
- globals={"a": ["a", "b", "c"]},
10
- expect="3",
11
- ),
12
- Case(
13
- description="size of a string",
14
- template=r"{{ a | size }}",
15
- globals={"a": "abc"},
16
- expect="3",
17
- ),
18
- Case(
19
- description="size of an empty array",
20
- template=r"{{ a | size }}",
21
- globals={"a": []},
22
- expect="0",
23
- ),
24
- Case(
25
- description="size of a hash",
26
- template=r"{{ a | size }}",
27
- globals={"a": {"a": 1, "b": 2}},
28
- expect="2",
29
- ),
30
- Case(
31
- description="unexpected argument",
32
- template=r"{{ a | size: 'foo' }}",
33
- globals={"a": [1, 2, 3]},
34
- expect="",
35
- error=True,
36
- ),
37
- Case(
38
- description="undefined left value",
39
- template=r"{{ nosuchthing | size }}",
40
- expect="0",
41
- ),
42
- ]
@@ -1,119 +0,0 @@
1
- """Golden tests cases for testing liquid's built-in `slice` filter."""
2
-
3
- from liquid.golden.case import Case
4
-
5
- cases = [
6
- Case(
7
- description="zero",
8
- template=r'{{ "hello" | slice: 0 }}',
9
- expect="h",
10
- ),
11
- Case(
12
- description="one",
13
- template=r'{{ "hello" | slice: 1 }}',
14
- expect="e",
15
- ),
16
- Case(
17
- description="one length three",
18
- template=r'{{ "hello" | slice: 1, 3 }}',
19
- expect="ell",
20
- ),
21
- Case(
22
- description="out of range",
23
- template=r'{{ "hello" | slice: 99 }}',
24
- expect="",
25
- ),
26
- Case(
27
- description="not a string",
28
- template=r"{{ 5 | slice: 1 }}",
29
- expect="",
30
- ),
31
- Case(
32
- description="first argument is a string",
33
- template=r'{{ "hello" | slice: "2" }}',
34
- expect="l",
35
- ),
36
- Case(
37
- description="first argument not an integer",
38
- template=r'{{ "hello" | slice: "foo" }}',
39
- expect="",
40
- error=True,
41
- ),
42
- Case(
43
- description="second argument not an integer",
44
- template=r'{{ "hello" | slice: 5, "foo" }}',
45
- expect="",
46
- error=True,
47
- ),
48
- Case(
49
- description="second argument is a string",
50
- template=r'{{ "hello" | slice: 3, "2" }}',
51
- expect="lo",
52
- ),
53
- Case(
54
- description="missing arguments",
55
- template=r'{{ "hello" | slice }}',
56
- expect="",
57
- error=True,
58
- ),
59
- Case(
60
- description="too many arguments",
61
- template=r'{{ "hello" | slice: 1, 2, 3 }}',
62
- expect="",
63
- error=True,
64
- ),
65
- Case(
66
- description="undefined left value",
67
- template=r"{{ nosuchthing | slice: 1, 3 }}",
68
- expect="",
69
- ),
70
- Case(
71
- description="undefined first argument",
72
- template=r'{{ "hello" | slice: nosuchthing, 3 }}',
73
- expect="",
74
- error=True,
75
- ),
76
- Case(
77
- description="undefined second argument",
78
- template=r'{{ "hello" | slice: 1, nosuchthing }}',
79
- expect="e",
80
- ),
81
- Case(
82
- description="slice an array of numbers",
83
- template=r"{{ a | slice: 2, 3 | join: '#' }}",
84
- expect="3#4#5",
85
- globals={"a": [1, 2, 3, 4, 5]},
86
- ),
87
- Case(
88
- description="first argument is a float",
89
- template=r"{{ 'Liquid' | slice: 2.2 }}",
90
- expect="",
91
- error=True,
92
- ),
93
- Case(
94
- description="second argument is a float",
95
- template=r"{{ 'Liquid' | slice: 1, 2.2 }}",
96
- expect="",
97
- error=True,
98
- ),
99
- Case(
100
- description="negative first argument",
101
- template=r"{{ 'Liquid' | slice: -2 }}",
102
- expect="i",
103
- ),
104
- Case(
105
- description="negative first argument and positive length",
106
- template=r"{{ 'Liquid' | slice: -2, 2 }}",
107
- expect="id",
108
- ),
109
- Case(
110
- description="negative first argument and negative length",
111
- template=r"{{ 'Liquid' | slice: -2, -1 }}",
112
- expect="",
113
- ),
114
- Case(
115
- description="negative first argument and length out of range",
116
- template=r"{{ 'Liquid' | slice: -2, 99 }}",
117
- expect="id",
118
- ),
119
- ]
@@ -1,86 +0,0 @@
1
- """Golden tests cases for testing liquid's built-in `sort` filter."""
2
-
3
- from liquid.golden.case import Case
4
-
5
- cases = [
6
- Case(
7
- description="array of strings",
8
- template=r"{{ a | sort | join: '#' }}",
9
- expect="A#B#C#a#b",
10
- globals={"a": ["b", "a", "C", "B", "A"]},
11
- ),
12
- Case(
13
- description="array of objects",
14
- template=(
15
- r"{% assign x = a | sort: 'title' %}"
16
- r"{% for obj in x %}"
17
- r"{% for i in obj %}"
18
- r"({{ i[0] }},{{ i[1] }})"
19
- r"{% endfor %}"
20
- r"{% endfor %}"
21
- ),
22
- expect="(title,Baz)(title,bar)(title,foo)",
23
- globals={"a": [{"title": "foo"}, {"title": "Baz"}, {"title": "bar"}]},
24
- ),
25
- Case(
26
- description="array of objects with missing key",
27
- template=(
28
- r"{% assign x = a | sort: 'title' %}"
29
- r"{% for obj in x %}"
30
- r"{% for i in obj %}"
31
- r"({{ i[0] }},{{ i[1] }})"
32
- r"{% endfor %}"
33
- r"{% endfor %}"
34
- ),
35
- expect="(title,bar)(title,foo)(heading,Baz)",
36
- globals={"a": [{"title": "foo"}, {"heading": "Baz"}, {"title": "bar"}]},
37
- ),
38
- Case(
39
- description="empty array",
40
- template=r"{{ a | sort | join: '#' }}",
41
- expect="",
42
- globals={"a": []},
43
- ),
44
- Case(
45
- description="too many arguments",
46
- template=r"{{ a | sort: 'title', 'foo' | join: '#' }}",
47
- expect="",
48
- globals={"a": ["b", "a"]},
49
- error=True,
50
- ),
51
- Case(
52
- description="left value is not an array",
53
- template=r"{{ a | sort | join: '#' }}",
54
- expect="123",
55
- globals={"a": 123},
56
- ),
57
- Case(
58
- description="left value is undefined",
59
- template=r"{{ nosuchthing | sort | join: '#' }}",
60
- expect="",
61
- ),
62
- Case(
63
- description="argument is undefined",
64
- template=r"{{ a | sort: nosuchthing | join: '#' }}",
65
- expect="a#b",
66
- globals={"a": ["b", "a"]},
67
- ),
68
- Case(
69
- description="sort a string",
70
- template=r"{{ 'BzAa4' | sort | join: '#' }}",
71
- expect="BzAa4",
72
- ),
73
- Case(
74
- description="array of integers",
75
- template=r"{{ a | sort | join: '#' }}",
76
- expect="1#3#30#1000",
77
- globals={"a": [1, 1000, 3, 30]},
78
- ),
79
- Case(
80
- description="incompatible types",
81
- template=r"{{ a | sort }}",
82
- expect="",
83
- globals={"a": [[], {}, 1, "4"]},
84
- error=True,
85
- ),
86
- ]
@@ -1,105 +0,0 @@
1
- """Golden tests cases for testing liquid's built-in `sort_natural` filter."""
2
-
3
- from liquid.golden.case import Case
4
-
5
- cases = [
6
- Case(
7
- description="array of strings",
8
- template=r"{{ a | sort_natural | join: '#' }}",
9
- expect="a#A#b#B#C",
10
- globals={"a": ["b", "a", "C", "B", "A"]},
11
- ),
12
- Case(
13
- description="array of strings with a nul",
14
- template=(
15
- r"{% assign x = a | sort_natural %}"
16
- r"{% for i in x %}"
17
- r"{{ i }}"
18
- r"{% unless forloop.last %}#{% endunless %}"
19
- r"{% endfor %}"
20
- ),
21
- expect="a#A#b#B#C#",
22
- globals={"a": ["b", "a", None, "C", "B", "A"]},
23
- ),
24
- Case(
25
- description="array of objects with a key",
26
- template=(
27
- r"{% assign x = a | sort_natural: 'title' %}"
28
- r"{% for obj in x %}"
29
- r"{% for i in obj %}"
30
- r"({{ i[0] }},{{ i[1] }})"
31
- r"{% endfor %}"
32
- r"{% endfor %}"
33
- ),
34
- expect="(title,bar)(title,Baz)(title,foo)",
35
- globals={"a": [{"title": "foo"}, {"title": "bar"}, {"title": "Baz"}]},
36
- ),
37
- Case(
38
- description="array of objects with a key gets stringified",
39
- template=(
40
- r"{% assign x = a | sort_natural: 'title' %}"
41
- r"{% for obj in x %}"
42
- r"{% for i in obj %}"
43
- r"({{ i[0] }},{{ i[1] }})"
44
- r"{% endfor %}"
45
- r"{% endfor %}"
46
- ),
47
- expect="(title,1111)(title,87)(title,9)",
48
- globals={"a": [{"title": 9}, {"title": 1111}, {"title": 87}]},
49
- ),
50
- Case(
51
- description="array of objects with a missing key",
52
- template=(
53
- r"{% assign x = a | sort_natural: 'title' %}"
54
- r"{% for obj in x %}"
55
- r"{% for i in obj %}"
56
- r"({{ i[0] }},{{ i[1] }})"
57
- r"{% endfor %}"
58
- r"{% endfor %}"
59
- ),
60
- expect="(title,bar)(title,foo)(heading,Baz)",
61
- globals={"a": [{"title": "foo"}, {"title": "bar"}, {"heading": "Baz"}]},
62
- ),
63
- Case(
64
- description="argument is undefined",
65
- template=(
66
- r"{% assign x = a | sort_natural: nosuchthing %}"
67
- r"{% for obj in x %}"
68
- r"{% for i in obj %}"
69
- r"({{ i[0] }},{{ i[1] }})"
70
- r"{% endfor %}"
71
- r"{% endfor %}"
72
- ),
73
- expect="(title,bar)(title,Baz)(title,foo)",
74
- globals={"a": [{"title": "foo"}, {"title": "bar"}, {"title": "Baz"}]},
75
- ),
76
- Case(
77
- description="empty array",
78
- template=(
79
- r"{% assign x = a | sort_natural %}"
80
- r"{% for i in x %}"
81
- r"{{ i }}"
82
- r"{% unless forloop.last %}#{% endunless %}"
83
- r"{% endfor %}"
84
- ),
85
- expect="",
86
- globals={"a": []},
87
- ),
88
- Case(
89
- description="left value is not an array",
90
- template=r"{{ a | sort_natural }}",
91
- expect="123",
92
- globals={"a": 123},
93
- ),
94
- Case(
95
- description="left value is undefined",
96
- template=r"{{ nosuchthing | sort_natural }}",
97
- expect="",
98
- ),
99
- Case(
100
- description="incompatible types",
101
- template=r"{{ a | sort_natural }}",
102
- expect="14{}",
103
- globals={"a": [{}, 1, "4"]},
104
- ),
105
- ]