python-liquid 2.0.0__tar.gz → 2.0.2__tar.gz
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.
- {python_liquid-2.0.0 → python_liquid-2.0.2}/PKG-INFO +6 -9
- {python_liquid-2.0.0 → python_liquid-2.0.2}/README.md +5 -8
- {python_liquid-2.0.0 → python_liquid-2.0.2}/liquid/__init__.py +1 -1
- {python_liquid-2.0.0 → python_liquid-2.0.2}/liquid/builtin/expressions/loop.py +2 -5
- {python_liquid-2.0.0 → python_liquid-2.0.2}/liquid/builtin/loaders/mixins.py +1 -2
- {python_liquid-2.0.0 → python_liquid-2.0.2}/liquid/extra/tags/macro_tag.py +2 -0
- {python_liquid-2.0.0 → python_liquid-2.0.2}/liquid/messages.py +1 -1
- {python_liquid-2.0.0 → python_liquid-2.0.2}/liquid/static_analysis.py +16 -10
- python_liquid-2.0.0/liquid/golden/__init__.py +0 -173
- python_liquid-2.0.0/liquid/golden/abs_filter.py +0 -73
- python_liquid-2.0.0/liquid/golden/append_filter.py +0 -43
- python_liquid-2.0.0/liquid/golden/assign_tag.py +0 -45
- python_liquid-2.0.0/liquid/golden/at_least_filter.py +0 -78
- python_liquid-2.0.0/liquid/golden/at_most_filter.py +0 -68
- python_liquid-2.0.0/liquid/golden/base64_decode_filter.py +0 -43
- python_liquid-2.0.0/liquid/golden/base64_encode_filter.py +0 -42
- python_liquid-2.0.0/liquid/golden/base64_url_safe_decode_filter.py +0 -43
- python_liquid-2.0.0/liquid/golden/base64_url_safe_encode_filter.py +0 -42
- python_liquid-2.0.0/liquid/golden/capitalize_filter.py +0 -27
- python_liquid-2.0.0/liquid/golden/capture_tag.py +0 -39
- python_liquid-2.0.0/liquid/golden/case.py +0 -28
- python_liquid-2.0.0/liquid/golden/case_tag.py +0 -226
- python_liquid-2.0.0/liquid/golden/ceil_filter.py +0 -63
- python_liquid-2.0.0/liquid/golden/comment_tag.py +0 -119
- python_liquid-2.0.0/liquid/golden/compact_filter.py +0 -54
- python_liquid-2.0.0/liquid/golden/concat_filter.py +0 -63
- python_liquid-2.0.0/liquid/golden/cycle_tag.py +0 -114
- python_liquid-2.0.0/liquid/golden/date_filter.py +0 -63
- python_liquid-2.0.0/liquid/golden/decrement_tag.py +0 -16
- python_liquid-2.0.0/liquid/golden/default_filter.py +0 -112
- python_liquid-2.0.0/liquid/golden/divided_by_filter.py +0 -101
- python_liquid-2.0.0/liquid/golden/doc_tag.py +0 -61
- python_liquid-2.0.0/liquid/golden/downcase_filter.py +0 -27
- python_liquid-2.0.0/liquid/golden/echo_tag.py +0 -116
- python_liquid-2.0.0/liquid/golden/escape_filter.py +0 -27
- python_liquid-2.0.0/liquid/golden/escape_once_filter.py +0 -32
- python_liquid-2.0.0/liquid/golden/find_filter.py +0 -90
- python_liquid-2.0.0/liquid/golden/find_index_filter.py +0 -96
- python_liquid-2.0.0/liquid/golden/first_filter.py +0 -51
- python_liquid-2.0.0/liquid/golden/floor_filter.py +0 -63
- python_liquid-2.0.0/liquid/golden/for_tag.py +0 -642
- python_liquid-2.0.0/liquid/golden/has_filter.py +0 -139
- python_liquid-2.0.0/liquid/golden/identifiers.py +0 -249
- python_liquid-2.0.0/liquid/golden/if_tag.py +0 -531
- python_liquid-2.0.0/liquid/golden/ifchanged_tag.py +0 -46
- python_liquid-2.0.0/liquid/golden/illegal.py +0 -34
- python_liquid-2.0.0/liquid/golden/include_tag.py +0 -196
- python_liquid-2.0.0/liquid/golden/increment_tag.py +0 -48
- python_liquid-2.0.0/liquid/golden/inline_comment_tag.py +0 -127
- python_liquid-2.0.0/liquid/golden/join_filter.py +0 -69
- python_liquid-2.0.0/liquid/golden/last_filter.py +0 -51
- python_liquid-2.0.0/liquid/golden/liquid_tag.py +0 -215
- python_liquid-2.0.0/liquid/golden/lstrip_filter.py +0 -37
- python_liquid-2.0.0/liquid/golden/map_filter.py +0 -50
- python_liquid-2.0.0/liquid/golden/minus_filter.py +0 -58
- python_liquid-2.0.0/liquid/golden/modulo_filter.py +0 -60
- python_liquid-2.0.0/liquid/golden/newline_to_br_filter.py +0 -37
- python_liquid-2.0.0/liquid/golden/not_liquid.py +0 -16
- python_liquid-2.0.0/liquid/golden/output_statement.py +0 -295
- python_liquid-2.0.0/liquid/golden/plus_filter.py +0 -63
- python_liquid-2.0.0/liquid/golden/prepend_filter.py +0 -43
- python_liquid-2.0.0/liquid/golden/range_objects.py +0 -79
- python_liquid-2.0.0/liquid/golden/raw_tag.py +0 -31
- python_liquid-2.0.0/liquid/golden/reject_filter.py +0 -268
- python_liquid-2.0.0/liquid/golden/remove_filter.py +0 -45
- python_liquid-2.0.0/liquid/golden/remove_first_filter.py +0 -46
- python_liquid-2.0.0/liquid/golden/remove_last_filter.py +0 -46
- python_liquid-2.0.0/liquid/golden/render_tag.py +0 -210
- python_liquid-2.0.0/liquid/golden/replace_filter.py +0 -65
- python_liquid-2.0.0/liquid/golden/replace_first_filter.py +0 -59
- python_liquid-2.0.0/liquid/golden/replace_last_filter.py +0 -60
- python_liquid-2.0.0/liquid/golden/reverse_filter.py +0 -42
- python_liquid-2.0.0/liquid/golden/round_filter.py +0 -87
- python_liquid-2.0.0/liquid/golden/rstrip_filter.py +0 -37
- python_liquid-2.0.0/liquid/golden/size_filter.py +0 -42
- python_liquid-2.0.0/liquid/golden/slice_filter.py +0 -119
- python_liquid-2.0.0/liquid/golden/sort_filter.py +0 -86
- python_liquid-2.0.0/liquid/golden/sort_natural_filter.py +0 -105
- python_liquid-2.0.0/liquid/golden/special.py +0 -91
- python_liquid-2.0.0/liquid/golden/split_filter.py +0 -128
- python_liquid-2.0.0/liquid/golden/strip_filter.py +0 -37
- python_liquid-2.0.0/liquid/golden/strip_html_filter.py +0 -74
- python_liquid-2.0.0/liquid/golden/strip_newlines_filter.py +0 -37
- python_liquid-2.0.0/liquid/golden/sum_filter.py +0 -97
- python_liquid-2.0.0/liquid/golden/tablerow_tag.py +0 -399
- python_liquid-2.0.0/liquid/golden/times_filter.py +0 -53
- python_liquid-2.0.0/liquid/golden/truncate_filter.py +0 -61
- python_liquid-2.0.0/liquid/golden/truncatewords_filter.py +0 -94
- python_liquid-2.0.0/liquid/golden/uniq_filter.py +0 -87
- python_liquid-2.0.0/liquid/golden/unless_tag.py +0 -101
- python_liquid-2.0.0/liquid/golden/upcase_filter.py +0 -27
- python_liquid-2.0.0/liquid/golden/url_decode_filter.py +0 -27
- python_liquid-2.0.0/liquid/golden/url_encode_filter.py +0 -27
- python_liquid-2.0.0/liquid/golden/where_filter.py +0 -122
- python_liquid-2.0.0/liquid/golden/whitespace_control.py +0 -281
- {python_liquid-2.0.0 → python_liquid-2.0.2}/.gitignore +0 -0
- {python_liquid-2.0.0 → python_liquid-2.0.2}/LICENSE +0 -0
- {python_liquid-2.0.0 → python_liquid-2.0.2}/liquid/analyze_tags.py +0 -0
- {python_liquid-2.0.0 → python_liquid-2.0.2}/liquid/ast.py +0 -0
- {python_liquid-2.0.0 → python_liquid-2.0.2}/liquid/builtin/__init__.py +0 -0
- {python_liquid-2.0.0 → python_liquid-2.0.2}/liquid/builtin/content.py +0 -0
- {python_liquid-2.0.0 → python_liquid-2.0.2}/liquid/builtin/drops/__init__.py +0 -0
- {python_liquid-2.0.0 → python_liquid-2.0.2}/liquid/builtin/drops/drops.py +0 -0
- {python_liquid-2.0.0 → python_liquid-2.0.2}/liquid/builtin/expressions/__init__.py +0 -0
- {python_liquid-2.0.0 → python_liquid-2.0.2}/liquid/builtin/expressions/_tokenize.py +0 -0
- {python_liquid-2.0.0 → python_liquid-2.0.2}/liquid/builtin/expressions/arguments.py +0 -0
- {python_liquid-2.0.0 → python_liquid-2.0.2}/liquid/builtin/expressions/filtered.py +0 -0
- {python_liquid-2.0.0 → python_liquid-2.0.2}/liquid/builtin/expressions/logical.py +0 -0
- {python_liquid-2.0.0 → python_liquid-2.0.2}/liquid/builtin/expressions/path.py +0 -0
- {python_liquid-2.0.0 → python_liquid-2.0.2}/liquid/builtin/expressions/primitive.py +0 -0
- {python_liquid-2.0.0 → python_liquid-2.0.2}/liquid/builtin/filters/__init__.py +0 -0
- {python_liquid-2.0.0 → python_liquid-2.0.2}/liquid/builtin/filters/array.py +0 -0
- {python_liquid-2.0.0 → python_liquid-2.0.2}/liquid/builtin/filters/extra.py +0 -0
- {python_liquid-2.0.0 → python_liquid-2.0.2}/liquid/builtin/filters/math.py +0 -0
- {python_liquid-2.0.0 → python_liquid-2.0.2}/liquid/builtin/filters/misc.py +0 -0
- {python_liquid-2.0.0 → python_liquid-2.0.2}/liquid/builtin/filters/string.py +0 -0
- {python_liquid-2.0.0 → python_liquid-2.0.2}/liquid/builtin/illegal.py +0 -0
- {python_liquid-2.0.0 → python_liquid-2.0.2}/liquid/builtin/loaders/__init__.py +0 -0
- {python_liquid-2.0.0 → python_liquid-2.0.2}/liquid/builtin/loaders/caching_file_system_loader.py +0 -0
- {python_liquid-2.0.0 → python_liquid-2.0.2}/liquid/builtin/loaders/choice_loader.py +0 -0
- {python_liquid-2.0.0 → python_liquid-2.0.2}/liquid/builtin/loaders/dict_loader.py +0 -0
- {python_liquid-2.0.0 → python_liquid-2.0.2}/liquid/builtin/loaders/file_system_loader.py +0 -0
- {python_liquid-2.0.0 → python_liquid-2.0.2}/liquid/builtin/loaders/package_loader.py +0 -0
- {python_liquid-2.0.0 → python_liquid-2.0.2}/liquid/builtin/output.py +0 -0
- {python_liquid-2.0.0 → python_liquid-2.0.2}/liquid/builtin/tags/__init__.py +0 -0
- {python_liquid-2.0.0 → python_liquid-2.0.2}/liquid/builtin/tags/assign_tag.py +0 -0
- {python_liquid-2.0.0 → python_liquid-2.0.2}/liquid/builtin/tags/capture_tag.py +0 -0
- {python_liquid-2.0.0 → python_liquid-2.0.2}/liquid/builtin/tags/case_tag.py +0 -0
- {python_liquid-2.0.0 → python_liquid-2.0.2}/liquid/builtin/tags/comment_tag.py +0 -0
- {python_liquid-2.0.0 → python_liquid-2.0.2}/liquid/builtin/tags/cycle_tag.py +0 -0
- {python_liquid-2.0.0 → python_liquid-2.0.2}/liquid/builtin/tags/decrement_tag.py +0 -0
- {python_liquid-2.0.0 → python_liquid-2.0.2}/liquid/builtin/tags/doc_tag.py +0 -0
- {python_liquid-2.0.0 → python_liquid-2.0.2}/liquid/builtin/tags/echo_tag.py +0 -0
- {python_liquid-2.0.0 → python_liquid-2.0.2}/liquid/builtin/tags/for_tag.py +0 -0
- {python_liquid-2.0.0 → python_liquid-2.0.2}/liquid/builtin/tags/if_tag.py +0 -0
- {python_liquid-2.0.0 → python_liquid-2.0.2}/liquid/builtin/tags/ifchanged_tag.py +0 -0
- {python_liquid-2.0.0 → python_liquid-2.0.2}/liquid/builtin/tags/include_tag.py +0 -0
- {python_liquid-2.0.0 → python_liquid-2.0.2}/liquid/builtin/tags/increment_tag.py +0 -0
- {python_liquid-2.0.0 → python_liquid-2.0.2}/liquid/builtin/tags/inline_comment_tag.py +0 -0
- {python_liquid-2.0.0 → python_liquid-2.0.2}/liquid/builtin/tags/liquid_tag.py +0 -0
- {python_liquid-2.0.0 → python_liquid-2.0.2}/liquid/builtin/tags/render_tag.py +0 -0
- {python_liquid-2.0.0 → python_liquid-2.0.2}/liquid/builtin/tags/tablerow_tag.py +0 -0
- {python_liquid-2.0.0 → python_liquid-2.0.2}/liquid/builtin/tags/unless_tag.py +0 -0
- {python_liquid-2.0.0 → python_liquid-2.0.2}/liquid/context.py +0 -0
- {python_liquid-2.0.0 → python_liquid-2.0.2}/liquid/environment.py +0 -0
- {python_liquid-2.0.0 → python_liquid-2.0.2}/liquid/exceptions.py +0 -0
- {python_liquid-2.0.0 → python_liquid-2.0.2}/liquid/expression.py +0 -0
- {python_liquid-2.0.0 → python_liquid-2.0.2}/liquid/extra/__init__.py +0 -0
- {python_liquid-2.0.0 → python_liquid-2.0.2}/liquid/extra/filters/__init__.py +0 -0
- {python_liquid-2.0.0 → python_liquid-2.0.2}/liquid/extra/filters/_json.py +0 -0
- {python_liquid-2.0.0 → python_liquid-2.0.2}/liquid/extra/filters/array.py +0 -0
- {python_liquid-2.0.0 → python_liquid-2.0.2}/liquid/extra/filters/babel.py +0 -0
- {python_liquid-2.0.0 → python_liquid-2.0.2}/liquid/extra/filters/html.py +0 -0
- {python_liquid-2.0.0 → python_liquid-2.0.2}/liquid/extra/filters/translate.py +0 -0
- {python_liquid-2.0.0 → python_liquid-2.0.2}/liquid/extra/tags/__init__.py +0 -0
- {python_liquid-2.0.0 → python_liquid-2.0.2}/liquid/extra/tags/_with.py +0 -0
- {python_liquid-2.0.0 → python_liquid-2.0.2}/liquid/extra/tags/extends_tag.py +0 -0
- {python_liquid-2.0.0 → python_liquid-2.0.2}/liquid/extra/tags/translate_tag.py +0 -0
- {python_liquid-2.0.0 → python_liquid-2.0.2}/liquid/filter.py +0 -0
- {python_liquid-2.0.0 → python_liquid-2.0.2}/liquid/future/__init__.py +0 -0
- {python_liquid-2.0.0 → python_liquid-2.0.2}/liquid/future/environment.py +0 -0
- {python_liquid-2.0.0 → python_liquid-2.0.2}/liquid/future/filters/__init__.py +0 -0
- {python_liquid-2.0.0 → python_liquid-2.0.2}/liquid/future/tags/__init__.py +0 -0
- {python_liquid-2.0.0 → python_liquid-2.0.2}/liquid/lex.py +0 -0
- {python_liquid-2.0.0 → python_liquid-2.0.2}/liquid/limits.py +0 -0
- {python_liquid-2.0.0 → python_liquid-2.0.2}/liquid/loader.py +0 -0
- {python_liquid-2.0.0 → python_liquid-2.0.2}/liquid/mode.py +0 -0
- {python_liquid-2.0.0 → python_liquid-2.0.2}/liquid/output.py +0 -0
- {python_liquid-2.0.0 → python_liquid-2.0.2}/liquid/parser.py +0 -0
- {python_liquid-2.0.0 → python_liquid-2.0.2}/liquid/py.typed +0 -0
- {python_liquid-2.0.0 → python_liquid-2.0.2}/liquid/span.py +0 -0
- {python_liquid-2.0.0 → python_liquid-2.0.2}/liquid/stream.py +0 -0
- {python_liquid-2.0.0 → python_liquid-2.0.2}/liquid/stringify.py +0 -0
- {python_liquid-2.0.0 → python_liquid-2.0.2}/liquid/tag.py +0 -0
- {python_liquid-2.0.0 → python_liquid-2.0.2}/liquid/template.py +0 -0
- {python_liquid-2.0.0 → python_liquid-2.0.2}/liquid/token.py +0 -0
- {python_liquid-2.0.0 → python_liquid-2.0.2}/liquid/undefined.py +0 -0
- {python_liquid-2.0.0 → python_liquid-2.0.2}/liquid/utils/__init__.py +0 -0
- {python_liquid-2.0.0 → python_liquid-2.0.2}/liquid/utils/chain_map.py +0 -0
- {python_liquid-2.0.0 → python_liquid-2.0.2}/liquid/utils/html.py +0 -0
- {python_liquid-2.0.0 → python_liquid-2.0.2}/liquid/utils/lru_cache.py +0 -0
- {python_liquid-2.0.0 → python_liquid-2.0.2}/liquid/utils/text.py +0 -0
- {python_liquid-2.0.0 → python_liquid-2.0.2}/pyproject.toml +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: python-liquid
|
|
3
|
-
Version: 2.0.
|
|
3
|
+
Version: 2.0.2
|
|
4
4
|
Summary: A Python engine for the Liquid template language.
|
|
5
5
|
Project-URL: Change Log, https://github.com/jg-rp/liquid/blob/main/CHANGES.md
|
|
6
6
|
Project-URL: Documentation, https://jg-rp.github.io/liquid/
|
|
@@ -36,23 +36,15 @@ Python Liquid is a Python engine for <a href="https://shopify.github.io/liquid/"
|
|
|
36
36
|
We follow <a href="https://github.com/Shopify/liquid">Shopify/Liquid</a> closely and test against the <a href="https://github.com/jg-rp/golden-liquid">Golden Liquid</a> test suite.
|
|
37
37
|
</p>
|
|
38
38
|
<p align="center">
|
|
39
|
-
<a href="https://github.com/jg-rp/liquid/blob/main/LICENSE">
|
|
40
|
-
<img src="https://img.shields.io/pypi/l/python-liquid.svg?style=flat-square" alt="License">
|
|
41
|
-
</a>
|
|
42
|
-
<br>
|
|
43
39
|
<a href="https://pypi.org/project/python-liquid/">
|
|
44
40
|
<img src="https://img.shields.io/pypi/v/python-liquid.svg?style=flat-square" alt="PyPi - Version">
|
|
45
41
|
</a>
|
|
46
42
|
<a href="https://anaconda.org/conda-forge/python-liquid">
|
|
47
43
|
<img src="https://img.shields.io/conda/vn/conda-forge/python-liquid?style=flat-square" alt="conda-forge">
|
|
48
44
|
</a>
|
|
49
|
-
<br>
|
|
50
45
|
<a href="https://pypi.org/project/python-liquid/">
|
|
51
46
|
<img src="https://img.shields.io/pypi/pyversions/python-liquid.svg?style=flat-square" alt="Python versions">
|
|
52
47
|
</a>
|
|
53
|
-
<a href="https://github.com/jg-rp/liquid/actions/workflows/coverage.yaml">
|
|
54
|
-
<img src="https://img.shields.io/badge/pypy-3.7%20%7C%203.8%20%7C%203.9-blue?style=flat-square" alt="PyPy versions">
|
|
55
|
-
</a>
|
|
56
48
|
<br>
|
|
57
49
|
<a href="https://github.com/jg-rp/liquid/actions/workflows/tests.yaml">
|
|
58
50
|
<img src="https://img.shields.io/github/actions/workflow/status/jg-rp/liquid/tests.yaml?branch=main&label=tests&style=flat-square" alt="Tests">
|
|
@@ -64,6 +56,10 @@ We follow <a href="https://github.com/Shopify/liquid">Shopify/Liquid</a> closely
|
|
|
64
56
|
<a href="https://pypi.org/project/python-liquid/">
|
|
65
57
|
<img alt="PyPI - Downloads" src="https://img.shields.io/pypi/dm/python-liquid?style=flat-square">
|
|
66
58
|
</a>
|
|
59
|
+
<br>
|
|
60
|
+
<a href="https://github.com/jg-rp/liquid/blob/main/LICENSE">
|
|
61
|
+
<img src="https://img.shields.io/pypi/l/python-liquid.svg?style=flat-square" alt="License">
|
|
62
|
+
</a>
|
|
67
63
|
</p>
|
|
68
64
|
|
|
69
65
|
---
|
|
@@ -108,6 +104,7 @@ $ conda install -c conda-forge python-liquid
|
|
|
108
104
|
## Related Projects
|
|
109
105
|
|
|
110
106
|
- [Python Liquid2](https://github.com/jg-rp/python-liquid2): A new Python engine for Liquid with [extra features](https://jg-rp.github.io/python-liquid2/migration/#new-features).
|
|
107
|
+
- [Ruby Liquid2](https://github.com/jg-rp/ruby-liquid2): Liquid2 templates for Ruby.
|
|
111
108
|
- [LiquidScript](https://github.com/jg-rp/liquidscript): A JavaScript engine for Liquid with a similar high-level API to Python Liquid.
|
|
112
109
|
|
|
113
110
|
## Quick Start
|
|
@@ -6,23 +6,15 @@ Python Liquid is a Python engine for <a href="https://shopify.github.io/liquid/"
|
|
|
6
6
|
We follow <a href="https://github.com/Shopify/liquid">Shopify/Liquid</a> closely and test against the <a href="https://github.com/jg-rp/golden-liquid">Golden Liquid</a> test suite.
|
|
7
7
|
</p>
|
|
8
8
|
<p align="center">
|
|
9
|
-
<a href="https://github.com/jg-rp/liquid/blob/main/LICENSE">
|
|
10
|
-
<img src="https://img.shields.io/pypi/l/python-liquid.svg?style=flat-square" alt="License">
|
|
11
|
-
</a>
|
|
12
|
-
<br>
|
|
13
9
|
<a href="https://pypi.org/project/python-liquid/">
|
|
14
10
|
<img src="https://img.shields.io/pypi/v/python-liquid.svg?style=flat-square" alt="PyPi - Version">
|
|
15
11
|
</a>
|
|
16
12
|
<a href="https://anaconda.org/conda-forge/python-liquid">
|
|
17
13
|
<img src="https://img.shields.io/conda/vn/conda-forge/python-liquid?style=flat-square" alt="conda-forge">
|
|
18
14
|
</a>
|
|
19
|
-
<br>
|
|
20
15
|
<a href="https://pypi.org/project/python-liquid/">
|
|
21
16
|
<img src="https://img.shields.io/pypi/pyversions/python-liquid.svg?style=flat-square" alt="Python versions">
|
|
22
17
|
</a>
|
|
23
|
-
<a href="https://github.com/jg-rp/liquid/actions/workflows/coverage.yaml">
|
|
24
|
-
<img src="https://img.shields.io/badge/pypy-3.7%20%7C%203.8%20%7C%203.9-blue?style=flat-square" alt="PyPy versions">
|
|
25
|
-
</a>
|
|
26
18
|
<br>
|
|
27
19
|
<a href="https://github.com/jg-rp/liquid/actions/workflows/tests.yaml">
|
|
28
20
|
<img src="https://img.shields.io/github/actions/workflow/status/jg-rp/liquid/tests.yaml?branch=main&label=tests&style=flat-square" alt="Tests">
|
|
@@ -34,6 +26,10 @@ We follow <a href="https://github.com/Shopify/liquid">Shopify/Liquid</a> closely
|
|
|
34
26
|
<a href="https://pypi.org/project/python-liquid/">
|
|
35
27
|
<img alt="PyPI - Downloads" src="https://img.shields.io/pypi/dm/python-liquid?style=flat-square">
|
|
36
28
|
</a>
|
|
29
|
+
<br>
|
|
30
|
+
<a href="https://github.com/jg-rp/liquid/blob/main/LICENSE">
|
|
31
|
+
<img src="https://img.shields.io/pypi/l/python-liquid.svg?style=flat-square" alt="License">
|
|
32
|
+
</a>
|
|
37
33
|
</p>
|
|
38
34
|
|
|
39
35
|
---
|
|
@@ -78,6 +74,7 @@ $ conda install -c conda-forge python-liquid
|
|
|
78
74
|
## Related Projects
|
|
79
75
|
|
|
80
76
|
- [Python Liquid2](https://github.com/jg-rp/python-liquid2): A new Python engine for Liquid with [extra features](https://jg-rp.github.io/python-liquid2/migration/#new-features).
|
|
77
|
+
- [Ruby Liquid2](https://github.com/jg-rp/ruby-liquid2): Liquid2 templates for Ruby.
|
|
81
78
|
- [LiquidScript](https://github.com/jg-rp/liquidscript): A JavaScript engine for Liquid with a similar high-level API to Python Liquid.
|
|
82
79
|
|
|
83
80
|
## Quick Start
|
|
@@ -97,14 +97,11 @@ class LoopExpression(Expression):
|
|
|
97
97
|
if isinstance(obj, range):
|
|
98
98
|
return iter(obj), len(obj)
|
|
99
99
|
if isinstance(obj, str) and not context.env.string_sequences:
|
|
100
|
-
return iter([obj]), 1
|
|
100
|
+
return (iter([]), 0) if not obj else (iter([obj]), 1)
|
|
101
101
|
if isinstance(obj, Sequence):
|
|
102
102
|
return iter(obj), len(obj)
|
|
103
103
|
|
|
104
|
-
|
|
105
|
-
f"expected an iterable at '{self.iterable}', found '{obj}'",
|
|
106
|
-
token=self.token,
|
|
107
|
-
)
|
|
104
|
+
return iter([]), 0
|
|
108
105
|
|
|
109
106
|
def _to_int(self, obj: object, *, token: Token) -> int:
|
|
110
107
|
try:
|
|
@@ -10,8 +10,7 @@ from typing import Awaitable
|
|
|
10
10
|
from typing import Callable
|
|
11
11
|
from typing import Mapping
|
|
12
12
|
from typing import Optional
|
|
13
|
-
|
|
14
|
-
from typing_extensions import Protocol
|
|
13
|
+
from typing import Protocol
|
|
15
14
|
|
|
16
15
|
from liquid.utils import LRUCache
|
|
17
16
|
from liquid.utils import ThreadSafeLRUCache
|
|
@@ -94,6 +94,8 @@ class MacroNode(Node):
|
|
|
94
94
|
|
|
95
95
|
def block_scope(self) -> Iterable[Identifier]:
|
|
96
96
|
"""Return variables this node adds to the node's block scope."""
|
|
97
|
+
yield Identifier("args", token=self.token)
|
|
98
|
+
yield Identifier("kwargs", token=self.token)
|
|
97
99
|
yield from (Identifier(p.name, token=p.token) for p in self.args.values())
|
|
98
100
|
|
|
99
101
|
|
|
@@ -12,10 +12,10 @@ from typing import Callable
|
|
|
12
12
|
from typing import Iterable
|
|
13
13
|
from typing import Iterator
|
|
14
14
|
from typing import NamedTuple
|
|
15
|
+
from typing import Protocol
|
|
15
16
|
from typing import Union
|
|
16
17
|
|
|
17
18
|
from babel.messages import Catalog
|
|
18
|
-
from typing_extensions import Protocol
|
|
19
19
|
|
|
20
20
|
from .builtin.expressions import Filter
|
|
21
21
|
from .builtin.expressions import FilteredExpression
|
|
@@ -301,19 +301,25 @@ async def _analyze_async(
|
|
|
301
301
|
def _extract_filters(
|
|
302
302
|
expression: Expression, template_name: str
|
|
303
303
|
) -> Iterable[tuple[str, Span]]:
|
|
304
|
-
if (
|
|
305
|
-
|
|
306
|
-
and expression.filters
|
|
307
|
-
):
|
|
308
|
-
yield from (
|
|
309
|
-
(f.name, Span(template_name, f.token.start_index))
|
|
310
|
-
for f in expression.filters
|
|
311
|
-
)
|
|
304
|
+
if isinstance(expression, TernaryFilteredExpression):
|
|
305
|
+
yield from _extract_filters(expression.left, template_name)
|
|
312
306
|
|
|
313
|
-
|
|
307
|
+
if expression.filters:
|
|
308
|
+
yield from (
|
|
309
|
+
(f.name, Span(template_name, f.token.start_index))
|
|
310
|
+
for f in expression.filters
|
|
311
|
+
)
|
|
312
|
+
|
|
313
|
+
if expression.tail_filters:
|
|
314
|
+
yield from (
|
|
315
|
+
(f.name, Span(template_name, f.token.start_index))
|
|
316
|
+
for f in expression.tail_filters
|
|
317
|
+
)
|
|
318
|
+
|
|
319
|
+
if isinstance(expression, FilteredExpression) and expression.filters:
|
|
314
320
|
yield from (
|
|
315
321
|
(f.name, Span(template_name, f.token.start_index))
|
|
316
|
-
for f in expression.
|
|
322
|
+
for f in expression.filters
|
|
317
323
|
)
|
|
318
324
|
|
|
319
325
|
for expr in expression.children():
|
|
@@ -1,173 +0,0 @@
|
|
|
1
|
-
from . import abs_filter # noqa: D104
|
|
2
|
-
from . import append_filter
|
|
3
|
-
from . import assign_tag
|
|
4
|
-
from . import at_least_filter
|
|
5
|
-
from . import at_most_filter
|
|
6
|
-
from . import base64_decode_filter
|
|
7
|
-
from . import base64_encode_filter
|
|
8
|
-
from . import base64_url_safe_decode_filter
|
|
9
|
-
from . import base64_url_safe_encode_filter
|
|
10
|
-
from . import capitalize_filter
|
|
11
|
-
from . import capture_tag
|
|
12
|
-
from . import case_tag
|
|
13
|
-
from . import ceil_filter
|
|
14
|
-
from . import comment_tag
|
|
15
|
-
from . import compact_filter
|
|
16
|
-
from . import concat_filter
|
|
17
|
-
from . import cycle_tag
|
|
18
|
-
from . import date_filter
|
|
19
|
-
from . import decrement_tag
|
|
20
|
-
from . import default_filter
|
|
21
|
-
from . import divided_by_filter
|
|
22
|
-
from . import doc_tag
|
|
23
|
-
from . import downcase_filter
|
|
24
|
-
from . import echo_tag
|
|
25
|
-
from . import escape_filter
|
|
26
|
-
from . import escape_once_filter
|
|
27
|
-
from . import find_filter
|
|
28
|
-
from . import find_index_filter
|
|
29
|
-
from . import first_filter
|
|
30
|
-
from . import floor_filter
|
|
31
|
-
from . import for_tag
|
|
32
|
-
from . import has_filter
|
|
33
|
-
from . import identifiers
|
|
34
|
-
from . import if_tag
|
|
35
|
-
from . import ifchanged_tag
|
|
36
|
-
from . import illegal
|
|
37
|
-
from . import include_tag
|
|
38
|
-
from . import increment_tag
|
|
39
|
-
from . import inline_comment_tag
|
|
40
|
-
from . import join_filter
|
|
41
|
-
from . import last_filter
|
|
42
|
-
from . import liquid_tag
|
|
43
|
-
from . import lstrip_filter
|
|
44
|
-
from . import map_filter
|
|
45
|
-
from . import minus_filter
|
|
46
|
-
from . import modulo_filter
|
|
47
|
-
from . import newline_to_br_filter
|
|
48
|
-
from . import not_liquid
|
|
49
|
-
from . import output_statement
|
|
50
|
-
from . import plus_filter
|
|
51
|
-
from . import prepend_filter
|
|
52
|
-
from . import range_objects
|
|
53
|
-
from . import raw_tag
|
|
54
|
-
from . import reject_filter
|
|
55
|
-
from . import remove_filter
|
|
56
|
-
from . import remove_first_filter
|
|
57
|
-
from . import remove_last_filter
|
|
58
|
-
from . import render_tag
|
|
59
|
-
from . import replace_filter
|
|
60
|
-
from . import replace_first_filter
|
|
61
|
-
from . import replace_last_filter
|
|
62
|
-
from . import reverse_filter
|
|
63
|
-
from . import round_filter
|
|
64
|
-
from . import rstrip_filter
|
|
65
|
-
from . import size_filter
|
|
66
|
-
from . import slice_filter
|
|
67
|
-
from . import sort_filter
|
|
68
|
-
from . import sort_natural_filter
|
|
69
|
-
from . import special
|
|
70
|
-
from . import split_filter
|
|
71
|
-
from . import strip_filter
|
|
72
|
-
from . import strip_html_filter
|
|
73
|
-
from . import strip_newlines_filter
|
|
74
|
-
from . import sum_filter
|
|
75
|
-
from . import tablerow_tag
|
|
76
|
-
from . import times_filter
|
|
77
|
-
from . import truncate_filter
|
|
78
|
-
from . import truncatewords_filter
|
|
79
|
-
from . import uniq_filter
|
|
80
|
-
from . import unless_tag
|
|
81
|
-
from . import upcase_filter
|
|
82
|
-
from . import url_decode_filter
|
|
83
|
-
from . import url_encode_filter
|
|
84
|
-
from . import where_filter
|
|
85
|
-
from . import whitespace_control
|
|
86
|
-
|
|
87
|
-
test_cases = [
|
|
88
|
-
abs_filter,
|
|
89
|
-
append_filter,
|
|
90
|
-
assign_tag,
|
|
91
|
-
at_least_filter,
|
|
92
|
-
at_most_filter,
|
|
93
|
-
base64_decode_filter,
|
|
94
|
-
base64_encode_filter,
|
|
95
|
-
base64_url_safe_decode_filter,
|
|
96
|
-
base64_url_safe_encode_filter,
|
|
97
|
-
capitalize_filter,
|
|
98
|
-
capture_tag,
|
|
99
|
-
case_tag,
|
|
100
|
-
ceil_filter,
|
|
101
|
-
comment_tag,
|
|
102
|
-
compact_filter,
|
|
103
|
-
concat_filter,
|
|
104
|
-
cycle_tag,
|
|
105
|
-
date_filter,
|
|
106
|
-
decrement_tag,
|
|
107
|
-
default_filter,
|
|
108
|
-
divided_by_filter,
|
|
109
|
-
doc_tag,
|
|
110
|
-
downcase_filter,
|
|
111
|
-
echo_tag,
|
|
112
|
-
escape_filter,
|
|
113
|
-
escape_once_filter,
|
|
114
|
-
find_filter,
|
|
115
|
-
find_index_filter,
|
|
116
|
-
first_filter,
|
|
117
|
-
floor_filter,
|
|
118
|
-
for_tag,
|
|
119
|
-
has_filter,
|
|
120
|
-
identifiers,
|
|
121
|
-
if_tag,
|
|
122
|
-
ifchanged_tag,
|
|
123
|
-
illegal,
|
|
124
|
-
include_tag,
|
|
125
|
-
increment_tag,
|
|
126
|
-
inline_comment_tag,
|
|
127
|
-
join_filter,
|
|
128
|
-
last_filter,
|
|
129
|
-
liquid_tag,
|
|
130
|
-
lstrip_filter,
|
|
131
|
-
map_filter,
|
|
132
|
-
minus_filter,
|
|
133
|
-
modulo_filter,
|
|
134
|
-
newline_to_br_filter,
|
|
135
|
-
not_liquid,
|
|
136
|
-
output_statement,
|
|
137
|
-
plus_filter,
|
|
138
|
-
prepend_filter,
|
|
139
|
-
range_objects,
|
|
140
|
-
raw_tag,
|
|
141
|
-
reject_filter,
|
|
142
|
-
remove_filter,
|
|
143
|
-
remove_first_filter,
|
|
144
|
-
remove_last_filter,
|
|
145
|
-
render_tag,
|
|
146
|
-
replace_filter,
|
|
147
|
-
replace_first_filter,
|
|
148
|
-
replace_last_filter,
|
|
149
|
-
reverse_filter,
|
|
150
|
-
round_filter,
|
|
151
|
-
rstrip_filter,
|
|
152
|
-
size_filter,
|
|
153
|
-
slice_filter,
|
|
154
|
-
sort_filter,
|
|
155
|
-
sort_natural_filter,
|
|
156
|
-
special,
|
|
157
|
-
split_filter,
|
|
158
|
-
strip_filter,
|
|
159
|
-
strip_html_filter,
|
|
160
|
-
strip_newlines_filter,
|
|
161
|
-
sum_filter,
|
|
162
|
-
tablerow_tag,
|
|
163
|
-
times_filter,
|
|
164
|
-
truncate_filter,
|
|
165
|
-
truncatewords_filter,
|
|
166
|
-
uniq_filter,
|
|
167
|
-
unless_tag,
|
|
168
|
-
upcase_filter,
|
|
169
|
-
url_decode_filter,
|
|
170
|
-
url_encode_filter,
|
|
171
|
-
where_filter,
|
|
172
|
-
whitespace_control,
|
|
173
|
-
]
|
|
@@ -1,73 +0,0 @@
|
|
|
1
|
-
"""Golden tests cases for testing liquid's built-in `abs` filter."""
|
|
2
|
-
|
|
3
|
-
from liquid.golden.case import Case
|
|
4
|
-
|
|
5
|
-
cases = [
|
|
6
|
-
Case(
|
|
7
|
-
description="positive integer",
|
|
8
|
-
template=r"{{ 5 | abs }}",
|
|
9
|
-
expect="5",
|
|
10
|
-
),
|
|
11
|
-
Case(
|
|
12
|
-
description="negative integer",
|
|
13
|
-
template=r"{{ -5 | abs }}",
|
|
14
|
-
expect="5",
|
|
15
|
-
),
|
|
16
|
-
Case(
|
|
17
|
-
description="positive float",
|
|
18
|
-
template=r"{{ 5.4 | abs }}",
|
|
19
|
-
expect="5.4",
|
|
20
|
-
),
|
|
21
|
-
Case(
|
|
22
|
-
description="negative float",
|
|
23
|
-
template=r"{{ -5.4 | abs }}",
|
|
24
|
-
expect="5.4",
|
|
25
|
-
),
|
|
26
|
-
Case(
|
|
27
|
-
description="zero",
|
|
28
|
-
template=r"{{ 0 | abs }}",
|
|
29
|
-
expect="0",
|
|
30
|
-
),
|
|
31
|
-
Case(
|
|
32
|
-
description="positive string integer",
|
|
33
|
-
template=r"{{ '5' | abs }}",
|
|
34
|
-
expect="5",
|
|
35
|
-
),
|
|
36
|
-
Case(
|
|
37
|
-
description="negative string integer",
|
|
38
|
-
template=r"{{ '-5' | abs }}",
|
|
39
|
-
expect="5",
|
|
40
|
-
),
|
|
41
|
-
Case(
|
|
42
|
-
description="positive string float",
|
|
43
|
-
template=r"{{ '5.1' | abs }}",
|
|
44
|
-
expect="5.1",
|
|
45
|
-
),
|
|
46
|
-
Case(
|
|
47
|
-
description="negative string float",
|
|
48
|
-
template=r"{{ '-5.1' | abs }}",
|
|
49
|
-
expect="5.1",
|
|
50
|
-
),
|
|
51
|
-
Case(
|
|
52
|
-
description="unexpected argument",
|
|
53
|
-
template=r"{{ -3 | abs: 1 }}",
|
|
54
|
-
expect="",
|
|
55
|
-
error=True,
|
|
56
|
-
),
|
|
57
|
-
Case(
|
|
58
|
-
description="string not a number",
|
|
59
|
-
template=r"{{ 'hello' | abs }}",
|
|
60
|
-
expect="0",
|
|
61
|
-
),
|
|
62
|
-
Case(
|
|
63
|
-
description="not a string, int or float",
|
|
64
|
-
template=r"{{ a | abs }}",
|
|
65
|
-
expect="0",
|
|
66
|
-
globals={"a": {}},
|
|
67
|
-
),
|
|
68
|
-
Case(
|
|
69
|
-
description="undefined left value",
|
|
70
|
-
template=r"{{ nosuchthing | abs }}",
|
|
71
|
-
expect="0",
|
|
72
|
-
),
|
|
73
|
-
]
|
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
"""Golden tests cases for testing liquid's built-in `append` filter."""
|
|
2
|
-
|
|
3
|
-
from liquid.golden.case import Case
|
|
4
|
-
|
|
5
|
-
cases = [
|
|
6
|
-
Case(
|
|
7
|
-
description="concat",
|
|
8
|
-
template=r'{{ "hello" | append: "there" }}',
|
|
9
|
-
expect="hellothere",
|
|
10
|
-
),
|
|
11
|
-
Case(
|
|
12
|
-
description="not a string",
|
|
13
|
-
template=r"{{ 5 | append: 'there' }}",
|
|
14
|
-
expect="5there",
|
|
15
|
-
),
|
|
16
|
-
Case(
|
|
17
|
-
description="argument not a string",
|
|
18
|
-
template=r'{{ "hello" | append: 5 }}',
|
|
19
|
-
expect="hello5",
|
|
20
|
-
),
|
|
21
|
-
Case(
|
|
22
|
-
description="missing argument",
|
|
23
|
-
template=r'{{ "hello" | append }}',
|
|
24
|
-
expect="",
|
|
25
|
-
error=True,
|
|
26
|
-
),
|
|
27
|
-
Case(
|
|
28
|
-
description="too many arguments",
|
|
29
|
-
template=r'{{ "hello" | append: "how", "are", "you" }}',
|
|
30
|
-
expect="",
|
|
31
|
-
error=True,
|
|
32
|
-
),
|
|
33
|
-
Case(
|
|
34
|
-
description="undefined left value",
|
|
35
|
-
template=r'{{ nosuchthing | append: "hi" }}',
|
|
36
|
-
expect="hi",
|
|
37
|
-
),
|
|
38
|
-
Case(
|
|
39
|
-
description="undefined argument",
|
|
40
|
-
template=r'{{ "hi" | append: nosuchthing }}',
|
|
41
|
-
expect="hi",
|
|
42
|
-
),
|
|
43
|
-
]
|
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
"""Golden tests cases for testing liquid's `assign` tag."""
|
|
2
|
-
|
|
3
|
-
from liquid.golden.case import Case
|
|
4
|
-
|
|
5
|
-
cases = [
|
|
6
|
-
Case(
|
|
7
|
-
description="assign a filtered literal",
|
|
8
|
-
template=r"{% assign foo = 'foo' | upcase %}{{ foo }}",
|
|
9
|
-
expect="FOO",
|
|
10
|
-
),
|
|
11
|
-
Case(
|
|
12
|
-
description="local variables shadow global variables",
|
|
13
|
-
template=r"{{ foo }}{% assign foo = 'foo' | upcase %}{{ foo }}",
|
|
14
|
-
expect="barFOO",
|
|
15
|
-
globals={"foo": "bar"},
|
|
16
|
-
),
|
|
17
|
-
Case(
|
|
18
|
-
description="assign a range literal",
|
|
19
|
-
template=r"{% assign foo = (1..3) %}{{ foo | join: '#' }}",
|
|
20
|
-
expect="1#2#3",
|
|
21
|
-
),
|
|
22
|
-
Case(
|
|
23
|
-
description="assign to variable with a hyphen",
|
|
24
|
-
template=r"{% assign some-thing = 'foo' %}{{ some-thing }}",
|
|
25
|
-
expect="foo",
|
|
26
|
-
),
|
|
27
|
-
Case(
|
|
28
|
-
description="assign an existing array",
|
|
29
|
-
template=r"{% assign foo = bar %}{{ foo[0] }}/{{ foo[1] }}",
|
|
30
|
-
expect="a/b",
|
|
31
|
-
globals={"bar": ["a", "b", "c"]},
|
|
32
|
-
),
|
|
33
|
-
Case(
|
|
34
|
-
description="assign an item from an existing object with quoted notation",
|
|
35
|
-
template=r"{% assign foo = bar['baz'] %}{{ foo }}",
|
|
36
|
-
expect="hello",
|
|
37
|
-
globals={"bar": {"baz": "hello"}},
|
|
38
|
-
),
|
|
39
|
-
Case(
|
|
40
|
-
description="assign with quoted notation and extra whitespace",
|
|
41
|
-
template=r"{% assign foo = bar[ 'baz' ] %}{{ foo }}",
|
|
42
|
-
expect="hello",
|
|
43
|
-
globals={"bar": {"baz": "hello"}},
|
|
44
|
-
),
|
|
45
|
-
]
|
|
@@ -1,78 +0,0 @@
|
|
|
1
|
-
"""Golden tests cases for testing liquid's built-in `at_least` filter."""
|
|
2
|
-
|
|
3
|
-
from liquid.golden.case import Case
|
|
4
|
-
|
|
5
|
-
cases = [
|
|
6
|
-
Case(
|
|
7
|
-
description="positive integer < arg",
|
|
8
|
-
template=r"{{ 5 | at_least: 8 }}",
|
|
9
|
-
expect="8",
|
|
10
|
-
),
|
|
11
|
-
Case(
|
|
12
|
-
description="positive integer > arg",
|
|
13
|
-
template=r"{{ 8 | at_least: 5 }}",
|
|
14
|
-
expect="8",
|
|
15
|
-
),
|
|
16
|
-
Case(
|
|
17
|
-
description="negative integer < arg",
|
|
18
|
-
template=r"{{ -8 | at_least: 5 }}",
|
|
19
|
-
expect="5",
|
|
20
|
-
),
|
|
21
|
-
Case(
|
|
22
|
-
description="positive integer == arg",
|
|
23
|
-
template=r"{{ 5 | at_least: 5 }}",
|
|
24
|
-
expect="5",
|
|
25
|
-
),
|
|
26
|
-
Case(
|
|
27
|
-
description="positive float < arg",
|
|
28
|
-
template=r"{{ 5.4 | at_least: 8.9 }}",
|
|
29
|
-
expect="8.9",
|
|
30
|
-
),
|
|
31
|
-
Case(
|
|
32
|
-
description="positive float > arg",
|
|
33
|
-
template=r"{{ 8.4 | at_least: 5.9 }}",
|
|
34
|
-
expect="8.4",
|
|
35
|
-
),
|
|
36
|
-
Case(
|
|
37
|
-
description="positive string > arg",
|
|
38
|
-
template=r'{{ "9" | at_least: 8 }}',
|
|
39
|
-
expect="9",
|
|
40
|
-
),
|
|
41
|
-
Case(
|
|
42
|
-
description="missing arg",
|
|
43
|
-
template=r"{{ 5 | at_least }}",
|
|
44
|
-
expect="",
|
|
45
|
-
error=True,
|
|
46
|
-
),
|
|
47
|
-
Case(
|
|
48
|
-
description="too many args",
|
|
49
|
-
template=r"{{ 5 | at_least: 1, 2}}",
|
|
50
|
-
expect="",
|
|
51
|
-
error=True,
|
|
52
|
-
),
|
|
53
|
-
Case(
|
|
54
|
-
description="undefined left value",
|
|
55
|
-
template=r"{{ nosuchthing | at_least: 5 }}",
|
|
56
|
-
expect="5",
|
|
57
|
-
),
|
|
58
|
-
Case(
|
|
59
|
-
description="undefined argument",
|
|
60
|
-
template=r"{{ 5 | at_least: nosuchthing }}",
|
|
61
|
-
expect="5",
|
|
62
|
-
),
|
|
63
|
-
Case(
|
|
64
|
-
description="left value not a number",
|
|
65
|
-
template=r'{{ "abc" | at_least: 2 }}',
|
|
66
|
-
expect="2",
|
|
67
|
-
),
|
|
68
|
-
Case(
|
|
69
|
-
description="left value not a number negative argument",
|
|
70
|
-
template=r'{{ "abc" | at_least: -2 }}',
|
|
71
|
-
expect="0",
|
|
72
|
-
),
|
|
73
|
-
Case(
|
|
74
|
-
description="argument string not a number",
|
|
75
|
-
template=r'{{ -1 | at_least: "abc" }}',
|
|
76
|
-
expect="0",
|
|
77
|
-
),
|
|
78
|
-
]
|
|
@@ -1,68 +0,0 @@
|
|
|
1
|
-
"""Golden tests cases for testing liquid's built-in `at_most` filter."""
|
|
2
|
-
|
|
3
|
-
from liquid.golden.case import Case
|
|
4
|
-
|
|
5
|
-
cases = [
|
|
6
|
-
Case(
|
|
7
|
-
description="positive integer < arg",
|
|
8
|
-
template=r"{{ 5 | at_most: 8 }}",
|
|
9
|
-
expect="5",
|
|
10
|
-
),
|
|
11
|
-
Case(
|
|
12
|
-
description="positive integer > arg",
|
|
13
|
-
template=r"{{ 8 | at_most: 5 }}",
|
|
14
|
-
expect="5",
|
|
15
|
-
),
|
|
16
|
-
Case(
|
|
17
|
-
description="negative integer < arg",
|
|
18
|
-
template=r"{{ -8 | at_most: 5 }}",
|
|
19
|
-
expect="-8",
|
|
20
|
-
),
|
|
21
|
-
Case(
|
|
22
|
-
description="positive integer == arg",
|
|
23
|
-
template=r"{{ 5 | at_most: 5 }}",
|
|
24
|
-
expect="5",
|
|
25
|
-
),
|
|
26
|
-
Case(
|
|
27
|
-
description="positive float < arg",
|
|
28
|
-
template=r"{{ 5.4 | at_most: 8.9 }}",
|
|
29
|
-
expect="5.4",
|
|
30
|
-
),
|
|
31
|
-
Case(
|
|
32
|
-
description="positive float > arg",
|
|
33
|
-
template=r"{{ 8.4 | at_most: 5.9 }}",
|
|
34
|
-
expect="5.9",
|
|
35
|
-
),
|
|
36
|
-
Case(
|
|
37
|
-
description="positive string > arg",
|
|
38
|
-
template=r'{{ "9" | at_most: 8 }}',
|
|
39
|
-
expect="8",
|
|
40
|
-
),
|
|
41
|
-
Case(
|
|
42
|
-
description="missing arg",
|
|
43
|
-
template=r"{{ 5 | at_most }}",
|
|
44
|
-
expect="",
|
|
45
|
-
error=True,
|
|
46
|
-
),
|
|
47
|
-
Case(
|
|
48
|
-
description="too many args",
|
|
49
|
-
template=r"{{ 5 | at_most: 1, 2}}",
|
|
50
|
-
expect="",
|
|
51
|
-
error=True,
|
|
52
|
-
),
|
|
53
|
-
Case(
|
|
54
|
-
description="undefined left value",
|
|
55
|
-
template=r"{{ nosuchthing | at_most: 5 }}",
|
|
56
|
-
expect="0",
|
|
57
|
-
),
|
|
58
|
-
Case(
|
|
59
|
-
description="undefined argument",
|
|
60
|
-
template=r"{{ 5 | at_most: nosuchthing }}",
|
|
61
|
-
expect="0",
|
|
62
|
-
),
|
|
63
|
-
Case(
|
|
64
|
-
description="left value not a number",
|
|
65
|
-
template=r'{{ "abc" | at_most: -2 }}',
|
|
66
|
-
expect="-2",
|
|
67
|
-
),
|
|
68
|
-
]
|