python-liquid 1.13.0__tar.gz → 2.0.0__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/PKG-INFO +169 -0
- python_liquid-2.0.0/README.md +139 -0
- python_liquid-2.0.0/liquid/__init__.py +246 -0
- {python_liquid-1.13.0 → python_liquid-2.0.0}/liquid/analyze_tags.py +28 -23
- python_liquid-2.0.0/liquid/ast.py +239 -0
- {python_liquid-1.13.0 → python_liquid-2.0.0}/liquid/builtin/__init__.py +34 -5
- python_liquid-2.0.0/liquid/builtin/content.py +41 -0
- python_liquid-2.0.0/liquid/builtin/expressions/__init__.py +47 -0
- python_liquid-2.0.0/liquid/builtin/expressions/_tokenize.py +186 -0
- python_liquid-2.0.0/liquid/builtin/expressions/arguments.py +207 -0
- python_liquid-2.0.0/liquid/builtin/expressions/filtered.py +387 -0
- python_liquid-2.0.0/liquid/builtin/expressions/logical.py +642 -0
- python_liquid-2.0.0/liquid/builtin/expressions/loop.py +278 -0
- python_liquid-2.0.0/liquid/builtin/expressions/path.py +163 -0
- python_liquid-2.0.0/liquid/builtin/expressions/primitive.py +417 -0
- {python_liquid-1.13.0 → python_liquid-2.0.0}/liquid/builtin/filters/array.py +144 -65
- {python_liquid-1.13.0 → python_liquid-2.0.0}/liquid/builtin/filters/extra.py +2 -5
- {python_liquid-1.13.0 → python_liquid-2.0.0}/liquid/builtin/filters/math.py +7 -12
- {python_liquid-1.13.0 → python_liquid-2.0.0}/liquid/builtin/filters/misc.py +5 -8
- {python_liquid-1.13.0 → python_liquid-2.0.0}/liquid/builtin/filters/string.py +37 -25
- python_liquid-2.0.0/liquid/builtin/illegal.py +28 -0
- {python_liquid-1.13.0 → python_liquid-2.0.0}/liquid/builtin/loaders/caching_file_system_loader.py +9 -27
- python_liquid-2.0.0/liquid/builtin/loaders/choice_loader.py +94 -0
- python_liquid-2.0.0/liquid/builtin/loaders/dict_loader.py +64 -0
- {python_liquid-1.13.0 → python_liquid-2.0.0}/liquid/builtin/loaders/file_system_loader.py +36 -53
- python_liquid-2.0.0/liquid/builtin/loaders/mixins.py +185 -0
- {python_liquid-1.13.0 → python_liquid-2.0.0}/liquid/builtin/loaders/package_loader.py +30 -20
- python_liquid-2.0.0/liquid/builtin/output.py +74 -0
- python_liquid-2.0.0/liquid/builtin/tags/assign_tag.py +75 -0
- python_liquid-2.0.0/liquid/builtin/tags/capture_tag.py +98 -0
- python_liquid-2.0.0/liquid/builtin/tags/case_tag.py +287 -0
- python_liquid-2.0.0/liquid/builtin/tags/comment_tag.py +77 -0
- python_liquid-2.0.0/liquid/builtin/tags/cycle_tag.py +127 -0
- python_liquid-2.0.0/liquid/builtin/tags/decrement_tag.py +59 -0
- python_liquid-2.0.0/liquid/builtin/tags/doc_tag.py +68 -0
- python_liquid-2.0.0/liquid/builtin/tags/echo_tag.py +45 -0
- {python_liquid-1.13.0 → python_liquid-2.0.0}/liquid/builtin/tags/for_tag.py +177 -213
- python_liquid-2.0.0/liquid/builtin/tags/if_tag.py +209 -0
- {python_liquid-1.13.0 → python_liquid-2.0.0}/liquid/builtin/tags/ifchanged_tag.py +33 -33
- python_liquid-2.0.0/liquid/builtin/tags/include_tag.py +251 -0
- python_liquid-2.0.0/liquid/builtin/tags/increment_tag.py +60 -0
- python_liquid-2.0.0/liquid/builtin/tags/inline_comment_tag.py +47 -0
- python_liquid-2.0.0/liquid/builtin/tags/liquid_tag.py +182 -0
- {python_liquid-1.13.0 → python_liquid-2.0.0}/liquid/builtin/tags/render_tag.py +136 -143
- {python_liquid-1.13.0 → python_liquid-2.0.0}/liquid/builtin/tags/tablerow_tag.py +57 -54
- python_liquid-2.0.0/liquid/builtin/tags/unless_tag.py +218 -0
- python_liquid-2.0.0/liquid/context.py +606 -0
- {python_liquid-1.13.0 → python_liquid-2.0.0}/liquid/environment.py +182 -370
- python_liquid-2.0.0/liquid/exceptions.py +284 -0
- python_liquid-2.0.0/liquid/expression.py +41 -0
- python_liquid-2.0.0/liquid/extra/__init__.py +97 -0
- python_liquid-2.0.0/liquid/extra/filters/__init__.py +33 -0
- {python_liquid-1.13.0 → python_liquid-2.0.0}/liquid/extra/filters/_json.py +1 -2
- {python_liquid-1.13.0 → python_liquid-2.0.0}/liquid/extra/filters/array.py +3 -4
- python_liquid-2.0.0/liquid/extra/filters/babel.py +552 -0
- python_liquid-2.0.0/liquid/extra/filters/translate.py +448 -0
- python_liquid-2.0.0/liquid/extra/tags/__init__.py +15 -0
- python_liquid-2.0.0/liquid/extra/tags/_with.py +83 -0
- python_liquid-2.0.0/liquid/extra/tags/extends_tag.py +577 -0
- python_liquid-2.0.0/liquid/extra/tags/macro_tag.py +268 -0
- python_liquid-2.0.0/liquid/extra/tags/translate_tag.py +388 -0
- {python_liquid-1.13.0 → python_liquid-2.0.0}/liquid/filter.py +24 -18
- {python_liquid-1.13.0 → python_liquid-2.0.0}/liquid/future/environment.py +10 -15
- python_liquid-2.0.0/liquid/future/filters/__init__.py +1 -0
- python_liquid-2.0.0/liquid/future/tags/__init__.py +1 -0
- {python_liquid-1.13.0 → python_liquid-2.0.0}/liquid/golden/__init__.py +10 -0
- {python_liquid-1.13.0 → python_liquid-2.0.0}/liquid/golden/case.py +3 -3
- python_liquid-2.0.0/liquid/golden/comment_tag.py +119 -0
- python_liquid-2.0.0/liquid/golden/doc_tag.py +61 -0
- python_liquid-2.0.0/liquid/golden/find_filter.py +90 -0
- python_liquid-2.0.0/liquid/golden/find_index_filter.py +96 -0
- python_liquid-2.0.0/liquid/golden/has_filter.py +139 -0
- {python_liquid-1.13.0 → python_liquid-2.0.0}/liquid/golden/if_tag.py +135 -0
- {python_liquid-1.13.0 → python_liquid-2.0.0}/liquid/golden/output_statement.py +57 -2
- python_liquid-2.0.0/liquid/golden/range_objects.py +79 -0
- python_liquid-2.0.0/liquid/golden/reject_filter.py +268 -0
- {python_liquid-1.13.0 → python_liquid-2.0.0}/liquid/golden/split_filter.py +31 -0
- python_liquid-2.0.0/liquid/lex.py +252 -0
- {python_liquid-1.13.0 → python_liquid-2.0.0}/liquid/limits.py +2 -1
- python_liquid-2.0.0/liquid/loader.py +141 -0
- python_liquid-2.0.0/liquid/messages.py +357 -0
- {python_liquid-1.13.0 → python_liquid-2.0.0}/liquid/output.py +10 -1
- python_liquid-2.0.0/liquid/parser.py +113 -0
- python_liquid-2.0.0/liquid/py.typed +0 -0
- python_liquid-2.0.0/liquid/span.py +35 -0
- python_liquid-2.0.0/liquid/static_analysis.py +364 -0
- python_liquid-2.0.0/liquid/stream.py +150 -0
- {python_liquid-1.13.0 → python_liquid-2.0.0}/liquid/tag.py +12 -11
- python_liquid-2.0.0/liquid/template.py +603 -0
- {python_liquid-1.13.0 → python_liquid-2.0.0}/liquid/token.py +29 -69
- {python_liquid-1.13.0 → python_liquid-2.0.0}/liquid/undefined.py +78 -18
- {python_liquid-1.13.0 → python_liquid-2.0.0}/liquid/utils/__init__.py +5 -1
- {python_liquid-1.13.0 → python_liquid-2.0.0}/liquid/utils/html.py +2 -4
- python_liquid-2.0.0/liquid/utils/lru_cache.py +129 -0
- {python_liquid-1.13.0 → python_liquid-2.0.0}/pyproject.toml +28 -36
- python_liquid-1.13.0/PKG-INFO +0 -186
- python_liquid-1.13.0/README.md +0 -153
- python_liquid-1.13.0/liquid/__init__.py +0 -85
- python_liquid-1.13.0/liquid/ast.py +0 -239
- python_liquid-1.13.0/liquid/builtin/illegal.py +0 -24
- python_liquid-1.13.0/liquid/builtin/literal.py +0 -47
- python_liquid-1.13.0/liquid/builtin/loaders/__init__.py +0 -133
- python_liquid-1.13.0/liquid/builtin/loaders/base_loader.py +0 -302
- python_liquid-1.13.0/liquid/builtin/loaders/choice_loader.py +0 -143
- python_liquid-1.13.0/liquid/builtin/loaders/mixins.py +0 -240
- python_liquid-1.13.0/liquid/builtin/statement.py +0 -65
- python_liquid-1.13.0/liquid/builtin/tags/assign_tag.py +0 -91
- python_liquid-1.13.0/liquid/builtin/tags/capture_tag.py +0 -108
- python_liquid-1.13.0/liquid/builtin/tags/case_tag.py +0 -217
- python_liquid-1.13.0/liquid/builtin/tags/comment_tag.py +0 -95
- python_liquid-1.13.0/liquid/builtin/tags/cycle_tag.py +0 -141
- python_liquid-1.13.0/liquid/builtin/tags/decrement_tag.py +0 -71
- python_liquid-1.13.0/liquid/builtin/tags/echo_tag.py +0 -46
- python_liquid-1.13.0/liquid/builtin/tags/if_tag.py +0 -260
- python_liquid-1.13.0/liquid/builtin/tags/include_tag.py +0 -256
- python_liquid-1.13.0/liquid/builtin/tags/increment_tag.py +0 -67
- python_liquid-1.13.0/liquid/builtin/tags/inline_comment_tag.py +0 -34
- python_liquid-1.13.0/liquid/builtin/tags/liquid_tag.py +0 -92
- python_liquid-1.13.0/liquid/builtin/tags/unless_tag.py +0 -254
- python_liquid-1.13.0/liquid/context.py +0 -765
- python_liquid-1.13.0/liquid/exceptions.py +0 -241
- python_liquid-1.13.0/liquid/expression.py +0 -1172
- python_liquid-1.13.0/liquid/expressions/__init__.py +0 -29
- python_liquid-1.13.0/liquid/expressions/arguments/__init__.py +0 -11
- python_liquid-1.13.0/liquid/expressions/arguments/lex.py +0 -105
- python_liquid-1.13.0/liquid/expressions/arguments/parse.py +0 -140
- python_liquid-1.13.0/liquid/expressions/boolean/__init__.py +0 -11
- python_liquid-1.13.0/liquid/expressions/boolean/lex.py +0 -188
- python_liquid-1.13.0/liquid/expressions/boolean/parse.py +0 -290
- python_liquid-1.13.0/liquid/expressions/common.py +0 -402
- python_liquid-1.13.0/liquid/expressions/conditional/__init__.py +0 -11
- python_liquid-1.13.0/liquid/expressions/conditional/lex.py +0 -196
- python_liquid-1.13.0/liquid/expressions/conditional/parse.py +0 -223
- python_liquid-1.13.0/liquid/expressions/filtered/__init__.py +0 -7
- python_liquid-1.13.0/liquid/expressions/filtered/lex.py +0 -109
- python_liquid-1.13.0/liquid/expressions/filtered/parse.py +0 -263
- python_liquid-1.13.0/liquid/expressions/include/__init__.py +0 -3
- python_liquid-1.13.0/liquid/expressions/include/lex.py +0 -109
- python_liquid-1.13.0/liquid/expressions/loop/__init__.py +0 -7
- python_liquid-1.13.0/liquid/expressions/loop/lex.py +0 -105
- python_liquid-1.13.0/liquid/expressions/loop/parse.py +0 -138
- python_liquid-1.13.0/liquid/expressions/stream.py +0 -106
- python_liquid-1.13.0/liquid/extra/__init__.py +0 -110
- python_liquid-1.13.0/liquid/extra/filters/__init__.py +0 -13
- python_liquid-1.13.0/liquid/extra/tags/__init__.py +0 -27
- python_liquid-1.13.0/liquid/extra/tags/_with.py +0 -94
- python_liquid-1.13.0/liquid/extra/tags/extends.py +0 -558
- python_liquid-1.13.0/liquid/extra/tags/if_expressions.py +0 -85
- python_liquid-1.13.0/liquid/extra/tags/if_not.py +0 -24
- python_liquid-1.13.0/liquid/extra/tags/macro.py +0 -326
- python_liquid-1.13.0/liquid/future/filters/__init__.py +0 -3
- python_liquid-1.13.0/liquid/future/filters/_split.py +0 -23
- python_liquid-1.13.0/liquid/future/tags/__init__.py +0 -11
- python_liquid-1.13.0/liquid/future/tags/_case_tag.py +0 -182
- python_liquid-1.13.0/liquid/future/tags/_if_tag.py +0 -8
- python_liquid-1.13.0/liquid/future/tags/_tablerow_tag.py +0 -14
- python_liquid-1.13.0/liquid/future/tags/_unless_tag.py +0 -8
- python_liquid-1.13.0/liquid/golden/comment_tag.py +0 -27
- python_liquid-1.13.0/liquid/golden/range_objects.py +0 -36
- python_liquid-1.13.0/liquid/lex.py +0 -525
- python_liquid-1.13.0/liquid/loaders.py +0 -30
- python_liquid-1.13.0/liquid/parse.py +0 -791
- python_liquid-1.13.0/liquid/static_analysis.py +0 -904
- python_liquid-1.13.0/liquid/stream.py +0 -87
- python_liquid-1.13.0/liquid/template.py +0 -453
- python_liquid-1.13.0/liquid/utils/cache.py +0 -194
- python_liquid-1.13.0/liquid/utils/cache.pyi +0 -13
- {python_liquid-1.13.0 → python_liquid-2.0.0}/.gitignore +0 -0
- {python_liquid-1.13.0 → python_liquid-2.0.0}/LICENSE +0 -0
- {python_liquid-1.13.0 → python_liquid-2.0.0}/liquid/builtin/drops/__init__.py +0 -0
- {python_liquid-1.13.0 → python_liquid-2.0.0}/liquid/builtin/drops/drops.py +0 -0
- {python_liquid-1.13.0 → python_liquid-2.0.0}/liquid/builtin/filters/__init__.py +0 -0
- {python_liquid-1.13.0/liquid/builtin/tags → python_liquid-2.0.0/liquid/builtin/loaders}/__init__.py +0 -0
- /python_liquid-1.13.0/liquid/py.typed → /python_liquid-2.0.0/liquid/builtin/tags/__init__.py +0 -0
- {python_liquid-1.13.0 → python_liquid-2.0.0}/liquid/extra/filters/html.py +0 -0
- {python_liquid-1.13.0 → python_liquid-2.0.0}/liquid/future/__init__.py +0 -0
- {python_liquid-1.13.0 → python_liquid-2.0.0}/liquid/golden/abs_filter.py +0 -0
- {python_liquid-1.13.0 → python_liquid-2.0.0}/liquid/golden/append_filter.py +0 -0
- {python_liquid-1.13.0 → python_liquid-2.0.0}/liquid/golden/assign_tag.py +0 -0
- {python_liquid-1.13.0 → python_liquid-2.0.0}/liquid/golden/at_least_filter.py +0 -0
- {python_liquid-1.13.0 → python_liquid-2.0.0}/liquid/golden/at_most_filter.py +0 -0
- {python_liquid-1.13.0 → python_liquid-2.0.0}/liquid/golden/base64_decode_filter.py +0 -0
- {python_liquid-1.13.0 → python_liquid-2.0.0}/liquid/golden/base64_encode_filter.py +0 -0
- {python_liquid-1.13.0 → python_liquid-2.0.0}/liquid/golden/base64_url_safe_decode_filter.py +0 -0
- {python_liquid-1.13.0 → python_liquid-2.0.0}/liquid/golden/base64_url_safe_encode_filter.py +0 -0
- {python_liquid-1.13.0 → python_liquid-2.0.0}/liquid/golden/capitalize_filter.py +0 -0
- {python_liquid-1.13.0 → python_liquid-2.0.0}/liquid/golden/capture_tag.py +0 -0
- {python_liquid-1.13.0 → python_liquid-2.0.0}/liquid/golden/case_tag.py +0 -0
- {python_liquid-1.13.0 → python_liquid-2.0.0}/liquid/golden/ceil_filter.py +0 -0
- {python_liquid-1.13.0 → python_liquid-2.0.0}/liquid/golden/compact_filter.py +0 -0
- {python_liquid-1.13.0 → python_liquid-2.0.0}/liquid/golden/concat_filter.py +0 -0
- {python_liquid-1.13.0 → python_liquid-2.0.0}/liquid/golden/cycle_tag.py +0 -0
- {python_liquid-1.13.0 → python_liquid-2.0.0}/liquid/golden/date_filter.py +0 -0
- {python_liquid-1.13.0 → python_liquid-2.0.0}/liquid/golden/decrement_tag.py +0 -0
- {python_liquid-1.13.0 → python_liquid-2.0.0}/liquid/golden/default_filter.py +0 -0
- {python_liquid-1.13.0 → python_liquid-2.0.0}/liquid/golden/divided_by_filter.py +0 -0
- {python_liquid-1.13.0 → python_liquid-2.0.0}/liquid/golden/downcase_filter.py +0 -0
- {python_liquid-1.13.0 → python_liquid-2.0.0}/liquid/golden/echo_tag.py +0 -0
- {python_liquid-1.13.0 → python_liquid-2.0.0}/liquid/golden/escape_filter.py +0 -0
- {python_liquid-1.13.0 → python_liquid-2.0.0}/liquid/golden/escape_once_filter.py +0 -0
- {python_liquid-1.13.0 → python_liquid-2.0.0}/liquid/golden/first_filter.py +0 -0
- {python_liquid-1.13.0 → python_liquid-2.0.0}/liquid/golden/floor_filter.py +0 -0
- {python_liquid-1.13.0 → python_liquid-2.0.0}/liquid/golden/for_tag.py +0 -0
- {python_liquid-1.13.0 → python_liquid-2.0.0}/liquid/golden/identifiers.py +0 -0
- {python_liquid-1.13.0 → python_liquid-2.0.0}/liquid/golden/ifchanged_tag.py +0 -0
- {python_liquid-1.13.0 → python_liquid-2.0.0}/liquid/golden/illegal.py +0 -0
- {python_liquid-1.13.0 → python_liquid-2.0.0}/liquid/golden/include_tag.py +0 -0
- {python_liquid-1.13.0 → python_liquid-2.0.0}/liquid/golden/increment_tag.py +0 -0
- {python_liquid-1.13.0 → python_liquid-2.0.0}/liquid/golden/inline_comment_tag.py +0 -0
- {python_liquid-1.13.0 → python_liquid-2.0.0}/liquid/golden/join_filter.py +0 -0
- {python_liquid-1.13.0 → python_liquid-2.0.0}/liquid/golden/last_filter.py +0 -0
- {python_liquid-1.13.0 → python_liquid-2.0.0}/liquid/golden/liquid_tag.py +0 -0
- {python_liquid-1.13.0 → python_liquid-2.0.0}/liquid/golden/lstrip_filter.py +0 -0
- {python_liquid-1.13.0 → python_liquid-2.0.0}/liquid/golden/map_filter.py +0 -0
- {python_liquid-1.13.0 → python_liquid-2.0.0}/liquid/golden/minus_filter.py +0 -0
- {python_liquid-1.13.0 → python_liquid-2.0.0}/liquid/golden/modulo_filter.py +0 -0
- {python_liquid-1.13.0 → python_liquid-2.0.0}/liquid/golden/newline_to_br_filter.py +0 -0
- {python_liquid-1.13.0 → python_liquid-2.0.0}/liquid/golden/not_liquid.py +0 -0
- {python_liquid-1.13.0 → python_liquid-2.0.0}/liquid/golden/plus_filter.py +0 -0
- {python_liquid-1.13.0 → python_liquid-2.0.0}/liquid/golden/prepend_filter.py +0 -0
- {python_liquid-1.13.0 → python_liquid-2.0.0}/liquid/golden/raw_tag.py +0 -0
- {python_liquid-1.13.0 → python_liquid-2.0.0}/liquid/golden/remove_filter.py +0 -0
- {python_liquid-1.13.0 → python_liquid-2.0.0}/liquid/golden/remove_first_filter.py +0 -0
- {python_liquid-1.13.0 → python_liquid-2.0.0}/liquid/golden/remove_last_filter.py +0 -0
- {python_liquid-1.13.0 → python_liquid-2.0.0}/liquid/golden/render_tag.py +0 -0
- {python_liquid-1.13.0 → python_liquid-2.0.0}/liquid/golden/replace_filter.py +0 -0
- {python_liquid-1.13.0 → python_liquid-2.0.0}/liquid/golden/replace_first_filter.py +0 -0
- {python_liquid-1.13.0 → python_liquid-2.0.0}/liquid/golden/replace_last_filter.py +0 -0
- {python_liquid-1.13.0 → python_liquid-2.0.0}/liquid/golden/reverse_filter.py +0 -0
- {python_liquid-1.13.0 → python_liquid-2.0.0}/liquid/golden/round_filter.py +0 -0
- {python_liquid-1.13.0 → python_liquid-2.0.0}/liquid/golden/rstrip_filter.py +0 -0
- {python_liquid-1.13.0 → python_liquid-2.0.0}/liquid/golden/size_filter.py +0 -0
- {python_liquid-1.13.0 → python_liquid-2.0.0}/liquid/golden/slice_filter.py +0 -0
- {python_liquid-1.13.0 → python_liquid-2.0.0}/liquid/golden/sort_filter.py +0 -0
- {python_liquid-1.13.0 → python_liquid-2.0.0}/liquid/golden/sort_natural_filter.py +0 -0
- {python_liquid-1.13.0 → python_liquid-2.0.0}/liquid/golden/special.py +0 -0
- {python_liquid-1.13.0 → python_liquid-2.0.0}/liquid/golden/strip_filter.py +0 -0
- {python_liquid-1.13.0 → python_liquid-2.0.0}/liquid/golden/strip_html_filter.py +0 -0
- {python_liquid-1.13.0 → python_liquid-2.0.0}/liquid/golden/strip_newlines_filter.py +0 -0
- {python_liquid-1.13.0 → python_liquid-2.0.0}/liquid/golden/sum_filter.py +0 -0
- {python_liquid-1.13.0 → python_liquid-2.0.0}/liquid/golden/tablerow_tag.py +0 -0
- {python_liquid-1.13.0 → python_liquid-2.0.0}/liquid/golden/times_filter.py +0 -0
- {python_liquid-1.13.0 → python_liquid-2.0.0}/liquid/golden/truncate_filter.py +0 -0
- {python_liquid-1.13.0 → python_liquid-2.0.0}/liquid/golden/truncatewords_filter.py +0 -0
- {python_liquid-1.13.0 → python_liquid-2.0.0}/liquid/golden/uniq_filter.py +0 -0
- {python_liquid-1.13.0 → python_liquid-2.0.0}/liquid/golden/unless_tag.py +0 -0
- {python_liquid-1.13.0 → python_liquid-2.0.0}/liquid/golden/upcase_filter.py +0 -0
- {python_liquid-1.13.0 → python_liquid-2.0.0}/liquid/golden/url_decode_filter.py +0 -0
- {python_liquid-1.13.0 → python_liquid-2.0.0}/liquid/golden/url_encode_filter.py +0 -0
- {python_liquid-1.13.0 → python_liquid-2.0.0}/liquid/golden/where_filter.py +0 -0
- {python_liquid-1.13.0 → python_liquid-2.0.0}/liquid/golden/whitespace_control.py +0 -0
- {python_liquid-1.13.0 → python_liquid-2.0.0}/liquid/mode.py +0 -0
- {python_liquid-1.13.0 → python_liquid-2.0.0}/liquid/stringify.py +0 -0
- {python_liquid-1.13.0/liquid → python_liquid-2.0.0/liquid/utils}/chain_map.py +0 -0
- {python_liquid-1.13.0 → python_liquid-2.0.0}/liquid/utils/text.py +0 -0
|
@@ -0,0 +1,169 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: python-liquid
|
|
3
|
+
Version: 2.0.0
|
|
4
|
+
Summary: A Python engine for the Liquid template language.
|
|
5
|
+
Project-URL: Change Log, https://github.com/jg-rp/liquid/blob/main/CHANGES.md
|
|
6
|
+
Project-URL: Documentation, https://jg-rp.github.io/liquid/
|
|
7
|
+
Project-URL: Homepage, https://jg-rp.github.io/liquid/
|
|
8
|
+
Project-URL: Issue Tracker, https://github.com/jg-rp/liquid/issues
|
|
9
|
+
Project-URL: Source Code, https://github.com/jg-rp/liquid
|
|
10
|
+
Author-email: James Prior <jamesgr.prior@gmail.com>
|
|
11
|
+
License-Expression: MIT
|
|
12
|
+
License-File: LICENSE
|
|
13
|
+
Classifier: Development Status :: 5 - Production/Stable
|
|
14
|
+
Classifier: Intended Audience :: Developers
|
|
15
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
16
|
+
Classifier: Programming Language :: Python :: 3
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.9
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
19
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
20
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
21
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
22
|
+
Classifier: Programming Language :: Python :: Implementation :: CPython
|
|
23
|
+
Classifier: Programming Language :: Python :: Implementation :: PyPy
|
|
24
|
+
Requires-Python: >=3.7
|
|
25
|
+
Requires-Dist: babel>=2
|
|
26
|
+
Requires-Dist: markupsafe>=3
|
|
27
|
+
Requires-Dist: python-dateutil>=2.8.1
|
|
28
|
+
Requires-Dist: pytz
|
|
29
|
+
Description-Content-Type: text/markdown
|
|
30
|
+
|
|
31
|
+
<h1 align="center">Python Liquid</h1>
|
|
32
|
+
|
|
33
|
+
<p align="center">
|
|
34
|
+
Python Liquid is a Python engine for <a href="https://shopify.github.io/liquid/">Liquid</a>, the safe, customer-facing template language.
|
|
35
|
+
<br>
|
|
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
|
+
</p>
|
|
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
|
+
<a href="https://pypi.org/project/python-liquid/">
|
|
44
|
+
<img src="https://img.shields.io/pypi/v/python-liquid.svg?style=flat-square" alt="PyPi - Version">
|
|
45
|
+
</a>
|
|
46
|
+
<a href="https://anaconda.org/conda-forge/python-liquid">
|
|
47
|
+
<img src="https://img.shields.io/conda/vn/conda-forge/python-liquid?style=flat-square" alt="conda-forge">
|
|
48
|
+
</a>
|
|
49
|
+
<br>
|
|
50
|
+
<a href="https://pypi.org/project/python-liquid/">
|
|
51
|
+
<img src="https://img.shields.io/pypi/pyversions/python-liquid.svg?style=flat-square" alt="Python versions">
|
|
52
|
+
</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
|
+
<br>
|
|
57
|
+
<a href="https://github.com/jg-rp/liquid/actions/workflows/tests.yaml">
|
|
58
|
+
<img src="https://img.shields.io/github/actions/workflow/status/jg-rp/liquid/tests.yaml?branch=main&label=tests&style=flat-square" alt="Tests">
|
|
59
|
+
</a>
|
|
60
|
+
<a href="https://github.com/jg-rp/liquid/actions/workflows/coverage.yaml">
|
|
61
|
+
<img src="https://img.shields.io/github/actions/workflow/status/jg-rp/liquid/coverage.yaml?branch=main&label=coverage&style=flat-square" alt="Coverage">
|
|
62
|
+
</a>
|
|
63
|
+
<br>
|
|
64
|
+
<a href="https://pypi.org/project/python-liquid/">
|
|
65
|
+
<img alt="PyPI - Downloads" src="https://img.shields.io/pypi/dm/python-liquid?style=flat-square">
|
|
66
|
+
</a>
|
|
67
|
+
</p>
|
|
68
|
+
|
|
69
|
+
---
|
|
70
|
+
|
|
71
|
+
**Table of Contents**
|
|
72
|
+
|
|
73
|
+
- [Install](#install)
|
|
74
|
+
- [Links](#links)
|
|
75
|
+
- [Related Projects](#related-projects)
|
|
76
|
+
- [Quick Start](#example)
|
|
77
|
+
- [Contributing](#contributing)
|
|
78
|
+
|
|
79
|
+
## Install
|
|
80
|
+
|
|
81
|
+
Install Python Liquid using [Pipenv](https://pipenv.pypa.io/en/latest/):
|
|
82
|
+
|
|
83
|
+
```shell
|
|
84
|
+
$ pipenv install -u python-liquid
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
Or [pip](https://pip.pypa.io/en/stable/getting-started/):
|
|
88
|
+
|
|
89
|
+
```shell
|
|
90
|
+
$ pip install python-liquid
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
Or from [conda-forge](https://anaconda.org/conda-forge/python-liquid):
|
|
94
|
+
|
|
95
|
+
```shell
|
|
96
|
+
$ conda install -c conda-forge python-liquid
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
## Links
|
|
100
|
+
|
|
101
|
+
- Documentation: https://jg-rp.github.io/liquid/
|
|
102
|
+
- Documentation for Python Liquid version 1.x: https://jg-rp.github.io/python-liquid-docs-archive/
|
|
103
|
+
- Change Log: https://github.com/jg-rp/liquid/blob/main/CHANGES.md
|
|
104
|
+
- PyPi: https://pypi.org/project/python-liquid/
|
|
105
|
+
- Source Code: https://github.com/jg-rp/liquid
|
|
106
|
+
- Issue Tracker: https://github.com/jg-rp/liquid/issues
|
|
107
|
+
|
|
108
|
+
## Related Projects
|
|
109
|
+
|
|
110
|
+
- [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).
|
|
111
|
+
- [LiquidScript](https://github.com/jg-rp/liquidscript): A JavaScript engine for Liquid with a similar high-level API to Python Liquid.
|
|
112
|
+
|
|
113
|
+
## Quick Start
|
|
114
|
+
|
|
115
|
+
### `render()`
|
|
116
|
+
|
|
117
|
+
This example renders a template from a string of text with the package-level `render()` function. The template has just one placeholder variable `you`, which we've given the value `"World"`.
|
|
118
|
+
|
|
119
|
+
```python
|
|
120
|
+
from liquid import render
|
|
121
|
+
|
|
122
|
+
print(render("Hello, {{ you }}!", you="World"))
|
|
123
|
+
# Hello, World!
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
### `parse()`
|
|
127
|
+
|
|
128
|
+
Often you'll want to render the same template several times with different variables. We can parse source text without immediately rendering it using the `parse()` function. `parse()` returns a `BoundTemplate` instance with a `render()` method.
|
|
129
|
+
|
|
130
|
+
```python
|
|
131
|
+
from liquid import parse
|
|
132
|
+
|
|
133
|
+
template = parse("Hello, {{ you }}!")
|
|
134
|
+
print(template.render(you="World")) # Hello, World!
|
|
135
|
+
print(template.render(you="Liquid")) # Hello, Liquid!
|
|
136
|
+
```
|
|
137
|
+
|
|
138
|
+
### Configure
|
|
139
|
+
|
|
140
|
+
Both `parse()` and `render()` are convenience functions that use the default Liquid environment. For all but the simplest cases, you'll want to configure an instance of `Environment`, then load and render templates from that.
|
|
141
|
+
|
|
142
|
+
```python
|
|
143
|
+
from liquid import CachingFileSystemLoader
|
|
144
|
+
from liquid import Environment
|
|
145
|
+
|
|
146
|
+
env = Environment(
|
|
147
|
+
autoescape=True,
|
|
148
|
+
loader=CachingFileSystemLoader("./templates"),
|
|
149
|
+
)
|
|
150
|
+
```
|
|
151
|
+
|
|
152
|
+
Then, using `env.parse()` or `env.get_template()`, we can create a `BoundTemplate` from a string or read from the file system, respectively.
|
|
153
|
+
|
|
154
|
+
```python
|
|
155
|
+
# ... continued from above
|
|
156
|
+
template = env.parse("Hello, {{ you }}!")
|
|
157
|
+
print(template.render(you="World")) # Hello, World!
|
|
158
|
+
|
|
159
|
+
# Try to load "./templates/index.html"
|
|
160
|
+
another_template = env.get_template("index.html")
|
|
161
|
+
data = {"some": {"thing": [1, 2, 3]}}
|
|
162
|
+
result = another_template.render(**data)
|
|
163
|
+
```
|
|
164
|
+
|
|
165
|
+
Unless you happen to have a relative folder called `templates` with a file called `index.html` within it, we would expect a `TemplateNotFoundError` to be raised when running the example above.
|
|
166
|
+
|
|
167
|
+
## Contributing
|
|
168
|
+
|
|
169
|
+
Please see [Contributing to Python Liquid](https://github.com/jg-rp/liquid/blob/main/contributing.md).
|
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
<h1 align="center">Python Liquid</h1>
|
|
2
|
+
|
|
3
|
+
<p align="center">
|
|
4
|
+
Python Liquid is a Python engine for <a href="https://shopify.github.io/liquid/">Liquid</a>, the safe, customer-facing template language.
|
|
5
|
+
<br>
|
|
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
|
+
</p>
|
|
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
|
+
<a href="https://pypi.org/project/python-liquid/">
|
|
14
|
+
<img src="https://img.shields.io/pypi/v/python-liquid.svg?style=flat-square" alt="PyPi - Version">
|
|
15
|
+
</a>
|
|
16
|
+
<a href="https://anaconda.org/conda-forge/python-liquid">
|
|
17
|
+
<img src="https://img.shields.io/conda/vn/conda-forge/python-liquid?style=flat-square" alt="conda-forge">
|
|
18
|
+
</a>
|
|
19
|
+
<br>
|
|
20
|
+
<a href="https://pypi.org/project/python-liquid/">
|
|
21
|
+
<img src="https://img.shields.io/pypi/pyversions/python-liquid.svg?style=flat-square" alt="Python versions">
|
|
22
|
+
</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
|
+
<br>
|
|
27
|
+
<a href="https://github.com/jg-rp/liquid/actions/workflows/tests.yaml">
|
|
28
|
+
<img src="https://img.shields.io/github/actions/workflow/status/jg-rp/liquid/tests.yaml?branch=main&label=tests&style=flat-square" alt="Tests">
|
|
29
|
+
</a>
|
|
30
|
+
<a href="https://github.com/jg-rp/liquid/actions/workflows/coverage.yaml">
|
|
31
|
+
<img src="https://img.shields.io/github/actions/workflow/status/jg-rp/liquid/coverage.yaml?branch=main&label=coverage&style=flat-square" alt="Coverage">
|
|
32
|
+
</a>
|
|
33
|
+
<br>
|
|
34
|
+
<a href="https://pypi.org/project/python-liquid/">
|
|
35
|
+
<img alt="PyPI - Downloads" src="https://img.shields.io/pypi/dm/python-liquid?style=flat-square">
|
|
36
|
+
</a>
|
|
37
|
+
</p>
|
|
38
|
+
|
|
39
|
+
---
|
|
40
|
+
|
|
41
|
+
**Table of Contents**
|
|
42
|
+
|
|
43
|
+
- [Install](#install)
|
|
44
|
+
- [Links](#links)
|
|
45
|
+
- [Related Projects](#related-projects)
|
|
46
|
+
- [Quick Start](#example)
|
|
47
|
+
- [Contributing](#contributing)
|
|
48
|
+
|
|
49
|
+
## Install
|
|
50
|
+
|
|
51
|
+
Install Python Liquid using [Pipenv](https://pipenv.pypa.io/en/latest/):
|
|
52
|
+
|
|
53
|
+
```shell
|
|
54
|
+
$ pipenv install -u python-liquid
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
Or [pip](https://pip.pypa.io/en/stable/getting-started/):
|
|
58
|
+
|
|
59
|
+
```shell
|
|
60
|
+
$ pip install python-liquid
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
Or from [conda-forge](https://anaconda.org/conda-forge/python-liquid):
|
|
64
|
+
|
|
65
|
+
```shell
|
|
66
|
+
$ conda install -c conda-forge python-liquid
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
## Links
|
|
70
|
+
|
|
71
|
+
- Documentation: https://jg-rp.github.io/liquid/
|
|
72
|
+
- Documentation for Python Liquid version 1.x: https://jg-rp.github.io/python-liquid-docs-archive/
|
|
73
|
+
- Change Log: https://github.com/jg-rp/liquid/blob/main/CHANGES.md
|
|
74
|
+
- PyPi: https://pypi.org/project/python-liquid/
|
|
75
|
+
- Source Code: https://github.com/jg-rp/liquid
|
|
76
|
+
- Issue Tracker: https://github.com/jg-rp/liquid/issues
|
|
77
|
+
|
|
78
|
+
## Related Projects
|
|
79
|
+
|
|
80
|
+
- [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).
|
|
81
|
+
- [LiquidScript](https://github.com/jg-rp/liquidscript): A JavaScript engine for Liquid with a similar high-level API to Python Liquid.
|
|
82
|
+
|
|
83
|
+
## Quick Start
|
|
84
|
+
|
|
85
|
+
### `render()`
|
|
86
|
+
|
|
87
|
+
This example renders a template from a string of text with the package-level `render()` function. The template has just one placeholder variable `you`, which we've given the value `"World"`.
|
|
88
|
+
|
|
89
|
+
```python
|
|
90
|
+
from liquid import render
|
|
91
|
+
|
|
92
|
+
print(render("Hello, {{ you }}!", you="World"))
|
|
93
|
+
# Hello, World!
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
### `parse()`
|
|
97
|
+
|
|
98
|
+
Often you'll want to render the same template several times with different variables. We can parse source text without immediately rendering it using the `parse()` function. `parse()` returns a `BoundTemplate` instance with a `render()` method.
|
|
99
|
+
|
|
100
|
+
```python
|
|
101
|
+
from liquid import parse
|
|
102
|
+
|
|
103
|
+
template = parse("Hello, {{ you }}!")
|
|
104
|
+
print(template.render(you="World")) # Hello, World!
|
|
105
|
+
print(template.render(you="Liquid")) # Hello, Liquid!
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
### Configure
|
|
109
|
+
|
|
110
|
+
Both `parse()` and `render()` are convenience functions that use the default Liquid environment. For all but the simplest cases, you'll want to configure an instance of `Environment`, then load and render templates from that.
|
|
111
|
+
|
|
112
|
+
```python
|
|
113
|
+
from liquid import CachingFileSystemLoader
|
|
114
|
+
from liquid import Environment
|
|
115
|
+
|
|
116
|
+
env = Environment(
|
|
117
|
+
autoescape=True,
|
|
118
|
+
loader=CachingFileSystemLoader("./templates"),
|
|
119
|
+
)
|
|
120
|
+
```
|
|
121
|
+
|
|
122
|
+
Then, using `env.parse()` or `env.get_template()`, we can create a `BoundTemplate` from a string or read from the file system, respectively.
|
|
123
|
+
|
|
124
|
+
```python
|
|
125
|
+
# ... continued from above
|
|
126
|
+
template = env.parse("Hello, {{ you }}!")
|
|
127
|
+
print(template.render(you="World")) # Hello, World!
|
|
128
|
+
|
|
129
|
+
# Try to load "./templates/index.html"
|
|
130
|
+
another_template = env.get_template("index.html")
|
|
131
|
+
data = {"some": {"thing": [1, 2, 3]}}
|
|
132
|
+
result = another_template.render(**data)
|
|
133
|
+
```
|
|
134
|
+
|
|
135
|
+
Unless you happen to have a relative folder called `templates` with a file called `index.html` within it, we would expect a `TemplateNotFoundError` to be raised when running the example above.
|
|
136
|
+
|
|
137
|
+
## Contributing
|
|
138
|
+
|
|
139
|
+
Please see [Contributing to Python Liquid](https://github.com/jg-rp/liquid/blob/main/contributing.md).
|
|
@@ -0,0 +1,246 @@
|
|
|
1
|
+
from pathlib import Path
|
|
2
|
+
from typing import Iterable
|
|
3
|
+
from typing import Iterator
|
|
4
|
+
from typing import Optional
|
|
5
|
+
from typing import TextIO
|
|
6
|
+
from typing import Union
|
|
7
|
+
|
|
8
|
+
from markupsafe import Markup
|
|
9
|
+
from markupsafe import escape
|
|
10
|
+
from markupsafe import soft_str
|
|
11
|
+
|
|
12
|
+
from .mode import Mode
|
|
13
|
+
from .token import Token
|
|
14
|
+
from .expression import Expression
|
|
15
|
+
|
|
16
|
+
from .context import RenderContext
|
|
17
|
+
from .context import FutureContext
|
|
18
|
+
from .undefined import DebugUndefined
|
|
19
|
+
from .undefined import is_undefined
|
|
20
|
+
from .undefined import FalsyStrictUndefined
|
|
21
|
+
from .undefined import StrictDefaultUndefined
|
|
22
|
+
from .undefined import StrictUndefined
|
|
23
|
+
from .undefined import Undefined
|
|
24
|
+
|
|
25
|
+
from .environment import Environment
|
|
26
|
+
from .environment import Template
|
|
27
|
+
|
|
28
|
+
from .template import AwareBoundTemplate
|
|
29
|
+
from .template import BoundTemplate
|
|
30
|
+
from .template import FutureAwareBoundTemplate
|
|
31
|
+
from .template import FutureBoundTemplate
|
|
32
|
+
|
|
33
|
+
from .builtin import CachingDictLoader
|
|
34
|
+
from .builtin import DictLoader
|
|
35
|
+
from .builtin import ChoiceLoader
|
|
36
|
+
from .builtin import CachingChoiceLoader
|
|
37
|
+
from .builtin import CachingFileSystemLoader
|
|
38
|
+
from .builtin import FileSystemLoader
|
|
39
|
+
from .builtin import PackageLoader
|
|
40
|
+
from .builtin import CachingLoaderMixin
|
|
41
|
+
from .loader import BaseLoader
|
|
42
|
+
|
|
43
|
+
from .ast import Node
|
|
44
|
+
from .ast import BlockNode
|
|
45
|
+
from .ast import ConditionalBlockNode
|
|
46
|
+
|
|
47
|
+
from .analyze_tags import TagAnalysis
|
|
48
|
+
from .analyze_tags import DEFAULT_INNER_TAG_MAP
|
|
49
|
+
|
|
50
|
+
from .messages import MessageTuple
|
|
51
|
+
from .messages import Translations
|
|
52
|
+
from .messages import extract_from_template
|
|
53
|
+
|
|
54
|
+
from .stream import TokenStream
|
|
55
|
+
from .tag import Tag
|
|
56
|
+
|
|
57
|
+
from . import future
|
|
58
|
+
|
|
59
|
+
__version__ = "2.0.0"
|
|
60
|
+
|
|
61
|
+
__all__ = (
|
|
62
|
+
"AwareBoundTemplate",
|
|
63
|
+
"BlockNode",
|
|
64
|
+
"BoundTemplate",
|
|
65
|
+
"CachingChoiceLoader",
|
|
66
|
+
"CachingDictLoader",
|
|
67
|
+
"CachingFileSystemLoader",
|
|
68
|
+
"CachingLoaderMixin",
|
|
69
|
+
"ChoiceLoader",
|
|
70
|
+
"ConditionalBlockNode",
|
|
71
|
+
"DebugUndefined",
|
|
72
|
+
"DEFAULT_INNER_TAG_MAP",
|
|
73
|
+
"DictLoader",
|
|
74
|
+
"Environment",
|
|
75
|
+
"escape",
|
|
76
|
+
"Expression",
|
|
77
|
+
"extract_from_template",
|
|
78
|
+
"FalsyStrictUndefined",
|
|
79
|
+
"FileSystemLoader",
|
|
80
|
+
"future",
|
|
81
|
+
"FutureAwareBoundTemplate",
|
|
82
|
+
"FutureBoundTemplate",
|
|
83
|
+
"FutureContext",
|
|
84
|
+
"is_undefined",
|
|
85
|
+
"make_choice_loader",
|
|
86
|
+
"make_file_system_loader",
|
|
87
|
+
"Markup",
|
|
88
|
+
"MessageTuple",
|
|
89
|
+
"Mode",
|
|
90
|
+
"Node",
|
|
91
|
+
"PackageLoader",
|
|
92
|
+
"parse",
|
|
93
|
+
"render_async",
|
|
94
|
+
"render",
|
|
95
|
+
"RenderContext",
|
|
96
|
+
"soft_str",
|
|
97
|
+
"StrictDefaultUndefined",
|
|
98
|
+
"StrictUndefined",
|
|
99
|
+
"Tag",
|
|
100
|
+
"TagAnalysis",
|
|
101
|
+
"Template",
|
|
102
|
+
"Token",
|
|
103
|
+
"TokenStream",
|
|
104
|
+
"Translations",
|
|
105
|
+
"Undefined",
|
|
106
|
+
)
|
|
107
|
+
|
|
108
|
+
DEFAULT_ENVIRONMENT = Environment()
|
|
109
|
+
|
|
110
|
+
|
|
111
|
+
def parse(source: str) -> BoundTemplate:
|
|
112
|
+
"""Parse template source text using the default environment."""
|
|
113
|
+
return DEFAULT_ENVIRONMENT.from_string(source)
|
|
114
|
+
|
|
115
|
+
|
|
116
|
+
def render(source: str, **data: object) -> str:
|
|
117
|
+
"""Parse and render source text using the default environment."""
|
|
118
|
+
return DEFAULT_ENVIRONMENT.render(source, **data)
|
|
119
|
+
|
|
120
|
+
|
|
121
|
+
async def render_async(source: str, **data: object) -> str:
|
|
122
|
+
"""Parse and render source text using the default environment."""
|
|
123
|
+
return await DEFAULT_ENVIRONMENT.render_async(source, **data)
|
|
124
|
+
|
|
125
|
+
|
|
126
|
+
def make_file_system_loader(
|
|
127
|
+
search_path: Union[str, Path, Iterable[Union[str, Path]]],
|
|
128
|
+
*,
|
|
129
|
+
encoding: str = "utf-8",
|
|
130
|
+
ext: str = ".liquid",
|
|
131
|
+
auto_reload: bool = True,
|
|
132
|
+
namespace_key: str = "",
|
|
133
|
+
cache_size: int = 300,
|
|
134
|
+
) -> BaseLoader:
|
|
135
|
+
"""A _file system_ template loader factory.
|
|
136
|
+
|
|
137
|
+
Returns one of `CachingFileSystemLoader` or `FileSystemLoader` depending in
|
|
138
|
+
the given arguments.
|
|
139
|
+
|
|
140
|
+
A `CachingFileSystemLoader` is returned if _cache_size_ is greater than 0.
|
|
141
|
+
Otherwise a `FileExtensionLoader` is returned if _ext_ is not empty.
|
|
142
|
+
If _ext_ is empty, a `FileSystemLoader` is returned.
|
|
143
|
+
|
|
144
|
+
_auto_reload_ and _namespace_key_ are ignored if _cache_key_ is less than 1.
|
|
145
|
+
|
|
146
|
+
Args:
|
|
147
|
+
search_path: One or more paths to search.
|
|
148
|
+
encoding: Open template files with the given encoding.
|
|
149
|
+
ext: A default file extension. Should include a leading period.
|
|
150
|
+
auto_reload: If `True`, automatically reload a cached template if it has been
|
|
151
|
+
updated.
|
|
152
|
+
namespace_key: The name of a global render context variable or loader keyword
|
|
153
|
+
argument that resolves to the current loader "namespace" or "scope".
|
|
154
|
+
|
|
155
|
+
If you're developing a multi-user application, a good namespace might be
|
|
156
|
+
`uid`, where `uid` is a unique identifier for a user and templates are
|
|
157
|
+
arranged in folders named for each `uid` inside the search path.
|
|
158
|
+
cache_size: The maximum number of templates to hold in the cache before removing
|
|
159
|
+
the least recently used template.
|
|
160
|
+
|
|
161
|
+
_New in version 1.12.0_
|
|
162
|
+
"""
|
|
163
|
+
if cache_size > 0:
|
|
164
|
+
return CachingFileSystemLoader(
|
|
165
|
+
search_path=search_path,
|
|
166
|
+
encoding=encoding,
|
|
167
|
+
ext=ext,
|
|
168
|
+
auto_reload=auto_reload,
|
|
169
|
+
namespace_key=namespace_key,
|
|
170
|
+
capacity=cache_size,
|
|
171
|
+
)
|
|
172
|
+
|
|
173
|
+
return FileSystemLoader(search_path=search_path, encoding=encoding, ext=ext)
|
|
174
|
+
|
|
175
|
+
|
|
176
|
+
def make_choice_loader(
|
|
177
|
+
loaders: list[BaseLoader],
|
|
178
|
+
*,
|
|
179
|
+
auto_reload: bool = True,
|
|
180
|
+
namespace_key: str = "",
|
|
181
|
+
cache_size: int = 300,
|
|
182
|
+
) -> BaseLoader:
|
|
183
|
+
"""A _choice loader_ factory.
|
|
184
|
+
|
|
185
|
+
Returns one of `CachingChoiceLoader` or `ChoiceLoader` depending on the
|
|
186
|
+
given arguments.
|
|
187
|
+
|
|
188
|
+
A `CachingChoiceLoader` is returned if _cache_size_ > 0, otherwise a
|
|
189
|
+
`ChoiceLoader` is returned.
|
|
190
|
+
|
|
191
|
+
_auto_reload_ and _namespace_key_ are ignored if _cache_key_ is less than 1.
|
|
192
|
+
|
|
193
|
+
Args:
|
|
194
|
+
loaders: A list of loaders implementing `liquid.loaders.BaseLoader`.
|
|
195
|
+
auto_reload: If `True`, automatically reload a cached template if it
|
|
196
|
+
has been updated.
|
|
197
|
+
namespace_key: The name of a global render context variable or loader
|
|
198
|
+
keyword argument that resolves to the current loader "namespace" or
|
|
199
|
+
"scope".
|
|
200
|
+
cache_size: The maximum number of templates to hold in the cache before
|
|
201
|
+
removing the least recently used template.
|
|
202
|
+
|
|
203
|
+
_New in version 1.12.0_
|
|
204
|
+
"""
|
|
205
|
+
if cache_size > 0:
|
|
206
|
+
return CachingChoiceLoader(
|
|
207
|
+
loaders=loaders,
|
|
208
|
+
auto_reload=auto_reload,
|
|
209
|
+
namespace_key=namespace_key,
|
|
210
|
+
capacity=cache_size,
|
|
211
|
+
)
|
|
212
|
+
|
|
213
|
+
return ChoiceLoader(loaders=loaders)
|
|
214
|
+
|
|
215
|
+
|
|
216
|
+
def extract_liquid(
|
|
217
|
+
fileobj: TextIO,
|
|
218
|
+
keywords: list[str],
|
|
219
|
+
comment_tags: Optional[list[str]] = None,
|
|
220
|
+
options: Optional[dict[object, object]] = None, # noqa: ARG001
|
|
221
|
+
) -> Iterator[MessageTuple]:
|
|
222
|
+
"""A babel compatible translation message extraction method for Liquid templates.
|
|
223
|
+
|
|
224
|
+
See https://babel.pocoo.org/en/latest/messages.html
|
|
225
|
+
|
|
226
|
+
Keywords are the names of Liquid filters or tags operating on translatable
|
|
227
|
+
strings. For a filter to contribute to message extraction, it must also
|
|
228
|
+
appear as a child of a `FilteredExpression` and be a `TranslatableFilter`.
|
|
229
|
+
Similarly, tags must produce a node that is a `TranslatableTag`.
|
|
230
|
+
|
|
231
|
+
Where a Liquid comment contains a prefix in `comment_tags`, the comment
|
|
232
|
+
will be attached to the translatable filter or tag immediately following
|
|
233
|
+
the comment. Python Liquid's non-standard shorthand comments are not
|
|
234
|
+
supported.
|
|
235
|
+
|
|
236
|
+
Options are arguments passed to the `liquid.Template` constructor with the
|
|
237
|
+
contents of `fileobj` as the template's source. Use `extract_from_template`
|
|
238
|
+
to extract messages from an existing template bound to an existing
|
|
239
|
+
environment.
|
|
240
|
+
"""
|
|
241
|
+
template = Environment(extra=True).parse(fileobj.read())
|
|
242
|
+
return extract_from_template(
|
|
243
|
+
template=template,
|
|
244
|
+
keywords=keywords,
|
|
245
|
+
comment_tags=comment_tags,
|
|
246
|
+
)
|