python-liquid 2.2.0__tar.gz → 2.2.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.2.0 → python_liquid-2.2.2}/PKG-INFO +1 -1
- {python_liquid-2.2.0 → python_liquid-2.2.2}/liquid/__init__.py +1 -1
- {python_liquid-2.2.0 → python_liquid-2.2.2}/liquid/builtin/loaders/file_system_loader.py +10 -0
- {python_liquid-2.2.0 → python_liquid-2.2.2}/liquid/builtin/tags/case_tag.py +1 -1
- {python_liquid-2.2.0 → python_liquid-2.2.2}/liquid/builtin/tags/cycle_tag.py +5 -0
- {python_liquid-2.2.0 → python_liquid-2.2.2}/liquid/context.py +7 -2
- {python_liquid-2.2.0 → python_liquid-2.2.2}/liquid/extra/tags/_with.py +10 -13
- {python_liquid-2.2.0 → python_liquid-2.2.2}/liquid/stream.py +1 -1
- {python_liquid-2.2.0 → python_liquid-2.2.2}/pyproject.toml +1 -0
- {python_liquid-2.2.0 → python_liquid-2.2.2}/.gitignore +0 -0
- {python_liquid-2.2.0 → python_liquid-2.2.2}/LICENSE +0 -0
- {python_liquid-2.2.0 → python_liquid-2.2.2}/README.md +0 -0
- {python_liquid-2.2.0 → python_liquid-2.2.2}/liquid/analyze_tags.py +0 -0
- {python_liquid-2.2.0 → python_liquid-2.2.2}/liquid/ast.py +0 -0
- {python_liquid-2.2.0 → python_liquid-2.2.2}/liquid/builtin/__init__.py +0 -0
- {python_liquid-2.2.0 → python_liquid-2.2.2}/liquid/builtin/content.py +0 -0
- {python_liquid-2.2.0 → python_liquid-2.2.2}/liquid/builtin/drops/__init__.py +0 -0
- {python_liquid-2.2.0 → python_liquid-2.2.2}/liquid/builtin/drops/drops.py +0 -0
- {python_liquid-2.2.0 → python_liquid-2.2.2}/liquid/builtin/expressions/__init__.py +0 -0
- {python_liquid-2.2.0 → python_liquid-2.2.2}/liquid/builtin/expressions/_tokenize.py +0 -0
- {python_liquid-2.2.0 → python_liquid-2.2.2}/liquid/builtin/expressions/arguments.py +0 -0
- {python_liquid-2.2.0 → python_liquid-2.2.2}/liquid/builtin/expressions/filtered.py +0 -0
- {python_liquid-2.2.0 → python_liquid-2.2.2}/liquid/builtin/expressions/logical.py +0 -0
- {python_liquid-2.2.0 → python_liquid-2.2.2}/liquid/builtin/expressions/loop.py +0 -0
- {python_liquid-2.2.0 → python_liquid-2.2.2}/liquid/builtin/expressions/path.py +0 -0
- {python_liquid-2.2.0 → python_liquid-2.2.2}/liquid/builtin/expressions/primitive.py +0 -0
- {python_liquid-2.2.0 → python_liquid-2.2.2}/liquid/builtin/filters/__init__.py +0 -0
- {python_liquid-2.2.0 → python_liquid-2.2.2}/liquid/builtin/filters/array.py +0 -0
- {python_liquid-2.2.0 → python_liquid-2.2.2}/liquid/builtin/filters/extra.py +0 -0
- {python_liquid-2.2.0 → python_liquid-2.2.2}/liquid/builtin/filters/math.py +0 -0
- {python_liquid-2.2.0 → python_liquid-2.2.2}/liquid/builtin/filters/misc.py +0 -0
- {python_liquid-2.2.0 → python_liquid-2.2.2}/liquid/builtin/filters/string.py +0 -0
- {python_liquid-2.2.0 → python_liquid-2.2.2}/liquid/builtin/illegal.py +0 -0
- {python_liquid-2.2.0 → python_liquid-2.2.2}/liquid/builtin/loaders/__init__.py +0 -0
- {python_liquid-2.2.0 → python_liquid-2.2.2}/liquid/builtin/loaders/caching_file_system_loader.py +0 -0
- {python_liquid-2.2.0 → python_liquid-2.2.2}/liquid/builtin/loaders/choice_loader.py +0 -0
- {python_liquid-2.2.0 → python_liquid-2.2.2}/liquid/builtin/loaders/dict_loader.py +0 -0
- {python_liquid-2.2.0 → python_liquid-2.2.2}/liquid/builtin/loaders/mixins.py +0 -0
- {python_liquid-2.2.0 → python_liquid-2.2.2}/liquid/builtin/loaders/package_loader.py +0 -0
- {python_liquid-2.2.0 → python_liquid-2.2.2}/liquid/builtin/output.py +0 -0
- {python_liquid-2.2.0 → python_liquid-2.2.2}/liquid/builtin/tags/__init__.py +0 -0
- {python_liquid-2.2.0 → python_liquid-2.2.2}/liquid/builtin/tags/assign_tag.py +0 -0
- {python_liquid-2.2.0 → python_liquid-2.2.2}/liquid/builtin/tags/capture_tag.py +0 -0
- {python_liquid-2.2.0 → python_liquid-2.2.2}/liquid/builtin/tags/comment_tag.py +0 -0
- {python_liquid-2.2.0 → python_liquid-2.2.2}/liquid/builtin/tags/decrement_tag.py +0 -0
- {python_liquid-2.2.0 → python_liquid-2.2.2}/liquid/builtin/tags/doc_tag.py +0 -0
- {python_liquid-2.2.0 → python_liquid-2.2.2}/liquid/builtin/tags/echo_tag.py +0 -0
- {python_liquid-2.2.0 → python_liquid-2.2.2}/liquid/builtin/tags/for_tag.py +0 -0
- {python_liquid-2.2.0 → python_liquid-2.2.2}/liquid/builtin/tags/if_tag.py +0 -0
- {python_liquid-2.2.0 → python_liquid-2.2.2}/liquid/builtin/tags/ifchanged_tag.py +0 -0
- {python_liquid-2.2.0 → python_liquid-2.2.2}/liquid/builtin/tags/include_tag.py +0 -0
- {python_liquid-2.2.0 → python_liquid-2.2.2}/liquid/builtin/tags/increment_tag.py +0 -0
- {python_liquid-2.2.0 → python_liquid-2.2.2}/liquid/builtin/tags/inline_comment_tag.py +0 -0
- {python_liquid-2.2.0 → python_liquid-2.2.2}/liquid/builtin/tags/liquid_tag.py +0 -0
- {python_liquid-2.2.0 → python_liquid-2.2.2}/liquid/builtin/tags/render_tag.py +0 -0
- {python_liquid-2.2.0 → python_liquid-2.2.2}/liquid/builtin/tags/tablerow_tag.py +0 -0
- {python_liquid-2.2.0 → python_liquid-2.2.2}/liquid/builtin/tags/unless_tag.py +0 -0
- {python_liquid-2.2.0 → python_liquid-2.2.2}/liquid/environment.py +0 -0
- {python_liquid-2.2.0 → python_liquid-2.2.2}/liquid/exceptions.py +0 -0
- {python_liquid-2.2.0 → python_liquid-2.2.2}/liquid/expression.py +0 -0
- {python_liquid-2.2.0 → python_liquid-2.2.2}/liquid/extra/__init__.py +0 -0
- {python_liquid-2.2.0 → python_liquid-2.2.2}/liquid/extra/filters/__init__.py +0 -0
- {python_liquid-2.2.0 → python_liquid-2.2.2}/liquid/extra/filters/_json.py +0 -0
- {python_liquid-2.2.0 → python_liquid-2.2.2}/liquid/extra/filters/array.py +0 -0
- {python_liquid-2.2.0 → python_liquid-2.2.2}/liquid/extra/filters/babel.py +0 -0
- {python_liquid-2.2.0 → python_liquid-2.2.2}/liquid/extra/filters/html.py +0 -0
- {python_liquid-2.2.0 → python_liquid-2.2.2}/liquid/extra/filters/translate.py +0 -0
- {python_liquid-2.2.0 → python_liquid-2.2.2}/liquid/extra/tags/__init__.py +0 -0
- {python_liquid-2.2.0 → python_liquid-2.2.2}/liquid/extra/tags/extends_tag.py +0 -0
- {python_liquid-2.2.0 → python_liquid-2.2.2}/liquid/extra/tags/macro_tag.py +0 -0
- {python_liquid-2.2.0 → python_liquid-2.2.2}/liquid/extra/tags/snippet_tag.py +0 -0
- {python_liquid-2.2.0 → python_liquid-2.2.2}/liquid/extra/tags/translate_tag.py +0 -0
- {python_liquid-2.2.0 → python_liquid-2.2.2}/liquid/filter.py +0 -0
- {python_liquid-2.2.0 → python_liquid-2.2.2}/liquid/future/__init__.py +0 -0
- {python_liquid-2.2.0 → python_liquid-2.2.2}/liquid/future/environment.py +0 -0
- {python_liquid-2.2.0 → python_liquid-2.2.2}/liquid/future/filters/__init__.py +0 -0
- {python_liquid-2.2.0 → python_liquid-2.2.2}/liquid/future/tags/__init__.py +0 -0
- {python_liquid-2.2.0 → python_liquid-2.2.2}/liquid/lex.py +0 -0
- {python_liquid-2.2.0 → python_liquid-2.2.2}/liquid/limits.py +0 -0
- {python_liquid-2.2.0 → python_liquid-2.2.2}/liquid/loader.py +0 -0
- {python_liquid-2.2.0 → python_liquid-2.2.2}/liquid/messages.py +0 -0
- {python_liquid-2.2.0 → python_liquid-2.2.2}/liquid/mode.py +0 -0
- {python_liquid-2.2.0 → python_liquid-2.2.2}/liquid/output.py +0 -0
- {python_liquid-2.2.0 → python_liquid-2.2.2}/liquid/parser.py +0 -0
- {python_liquid-2.2.0 → python_liquid-2.2.2}/liquid/py.typed +0 -0
- {python_liquid-2.2.0 → python_liquid-2.2.2}/liquid/span.py +0 -0
- {python_liquid-2.2.0 → python_liquid-2.2.2}/liquid/static_analysis.py +0 -0
- {python_liquid-2.2.0 → python_liquid-2.2.2}/liquid/stringify.py +0 -0
- {python_liquid-2.2.0 → python_liquid-2.2.2}/liquid/tag.py +0 -0
- {python_liquid-2.2.0 → python_liquid-2.2.2}/liquid/template.py +0 -0
- {python_liquid-2.2.0 → python_liquid-2.2.2}/liquid/token.py +0 -0
- {python_liquid-2.2.0 → python_liquid-2.2.2}/liquid/undefined.py +0 -0
- {python_liquid-2.2.0 → python_liquid-2.2.2}/liquid/utils/__init__.py +0 -0
- {python_liquid-2.2.0 → python_liquid-2.2.2}/liquid/utils/chain_map.py +0 -0
- {python_liquid-2.2.0 → python_liquid-2.2.2}/liquid/utils/html.py +0 -0
- {python_liquid-2.2.0 → python_liquid-2.2.2}/liquid/utils/lru_cache.py +0 -0
- {python_liquid-2.2.0 → python_liquid-2.2.2}/liquid/utils/text.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: python-liquid
|
|
3
|
-
Version: 2.2.
|
|
3
|
+
Version: 2.2.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/
|
|
@@ -29,6 +29,9 @@ class FileSystemLoader(BaseLoader):
|
|
|
29
29
|
ext: A default file extension. Should include a leading period.
|
|
30
30
|
reject_symlinks: When `True`, reject paths to symlinks that resolve to files
|
|
31
31
|
outside the search path. Defaults to `False`.
|
|
32
|
+
|
|
33
|
+
Raise:
|
|
34
|
+
ValueError if `ext` is not a valid suffix.
|
|
32
35
|
"""
|
|
33
36
|
|
|
34
37
|
def __init__(
|
|
@@ -48,6 +51,10 @@ class FileSystemLoader(BaseLoader):
|
|
|
48
51
|
self.ext = ext
|
|
49
52
|
self.reject_symlinks = reject_symlinks
|
|
50
53
|
|
|
54
|
+
# Raise a ValueError early if `ext` is invalid.
|
|
55
|
+
if ext:
|
|
56
|
+
Path("x").with_suffix(ext)
|
|
57
|
+
|
|
51
58
|
def resolve_path(self, template_name: str) -> Path:
|
|
52
59
|
"""Return a path to the template identified by _template_name_.
|
|
53
60
|
|
|
@@ -57,6 +64,9 @@ class FileSystemLoader(BaseLoader):
|
|
|
57
64
|
"""
|
|
58
65
|
template_path = Path(template_name)
|
|
59
66
|
|
|
67
|
+
if not template_path.name:
|
|
68
|
+
raise TemplateNotFoundError(template_name)
|
|
69
|
+
|
|
60
70
|
if self.ext and not template_path.suffix:
|
|
61
71
|
template_path = template_path.with_suffix(self.ext)
|
|
62
72
|
|
|
@@ -145,7 +145,7 @@ class CaseTag(Tag):
|
|
|
145
145
|
|
|
146
146
|
# Eat whitespace or junk between `case` and when/else/endcase
|
|
147
147
|
while (
|
|
148
|
-
stream.current.kind
|
|
148
|
+
stream.current.kind not in (TOKEN_TAG, TOKEN_EOF)
|
|
149
149
|
and stream.current.value not in ENDWHENBLOCK
|
|
150
150
|
):
|
|
151
151
|
next(stream)
|
|
@@ -11,6 +11,7 @@ from typing import TextIO
|
|
|
11
11
|
from liquid.ast import Node
|
|
12
12
|
from liquid.builtin.expressions import PositionalArgument
|
|
13
13
|
from liquid.builtin.expressions import parse_primitive
|
|
14
|
+
from liquid.exceptions import LiquidSyntaxError
|
|
14
15
|
from liquid.stringify import to_liquid_string
|
|
15
16
|
from liquid.tag import Tag
|
|
16
17
|
from liquid.token import TOKEN_COLON
|
|
@@ -124,4 +125,8 @@ class CycleTag(Tag):
|
|
|
124
125
|
tokens.eat(TOKEN_COLON)
|
|
125
126
|
|
|
126
127
|
args = PositionalArgument.parse(self.env, tokens)
|
|
128
|
+
|
|
129
|
+
if not args:
|
|
130
|
+
raise LiquidSyntaxError("expected at least one argument", token=token)
|
|
131
|
+
|
|
127
132
|
return self.node_class(token, group_name, [arg.value for arg in args])
|
|
@@ -175,7 +175,12 @@ class RenderContext:
|
|
|
175
175
|
"""
|
|
176
176
|
it = iter(path)
|
|
177
177
|
root = next(it)
|
|
178
|
-
|
|
178
|
+
|
|
179
|
+
if not isinstance(root, str):
|
|
180
|
+
if default == UNDEFINED:
|
|
181
|
+
hint = f"{root} is undefined"
|
|
182
|
+
return self.env.undefined(str(root), hint=hint, token=token)
|
|
183
|
+
return default
|
|
179
184
|
|
|
180
185
|
try:
|
|
181
186
|
obj = self.scope[root]
|
|
@@ -316,7 +321,7 @@ class RenderContext:
|
|
|
316
321
|
"""Return the index of the next item in the cycle."""
|
|
317
322
|
namespace: dict[object, int] = self.tag_namespace["cycles"]
|
|
318
323
|
idx = namespace.setdefault(key, 0)
|
|
319
|
-
namespace[key] = (idx + 1) % length
|
|
324
|
+
namespace[key] = (idx + 1) % (length or 1) # Just in case.
|
|
320
325
|
return idx
|
|
321
326
|
|
|
322
327
|
def ifchanged(self, val: str) -> bool:
|
|
@@ -35,16 +35,20 @@ class WithNode(Node):
|
|
|
35
35
|
self.block = block
|
|
36
36
|
self.blank = self.block.blank
|
|
37
37
|
|
|
38
|
-
def render_to_output(
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
38
|
+
def render_to_output(
|
|
39
|
+
self,
|
|
40
|
+
context: RenderContext,
|
|
41
|
+
buffer: TextIO,
|
|
42
|
+
) -> int:
|
|
43
|
+
with context.extend({a.name: a.value.evaluate(context) for a in self.args}):
|
|
42
44
|
return self.block.render(context, buffer)
|
|
43
45
|
|
|
44
46
|
async def render_to_output_async(
|
|
45
|
-
self,
|
|
47
|
+
self,
|
|
48
|
+
context: RenderContext,
|
|
49
|
+
buffer: TextIO,
|
|
46
50
|
) -> int:
|
|
47
|
-
namespace =
|
|
51
|
+
namespace = {a.name: await a.value.evaluate_async(context) for a in self.args}
|
|
48
52
|
with context.extend(namespace):
|
|
49
53
|
return await self.block.render_async(context, buffer)
|
|
50
54
|
|
|
@@ -54,21 +58,16 @@ class WithNode(Node):
|
|
|
54
58
|
*,
|
|
55
59
|
include_partials: bool = True, # noqa: ARG002
|
|
56
60
|
) -> Iterable[Node]:
|
|
57
|
-
"""Return this node's children."""
|
|
58
61
|
yield self.block
|
|
59
62
|
|
|
60
63
|
def expressions(self) -> Iterable[Expression]:
|
|
61
|
-
"""Return this node's expressions."""
|
|
62
64
|
yield from (arg.value for arg in self.args)
|
|
63
65
|
|
|
64
66
|
def block_scope(self) -> Iterable[Identifier]:
|
|
65
|
-
"""Return variables this node adds to the node's block scope."""
|
|
66
67
|
yield from (Identifier(p.name, token=p.token) for p in self.args)
|
|
67
68
|
|
|
68
69
|
|
|
69
70
|
class WithTag(Tag):
|
|
70
|
-
"""The extra _with_ tag."""
|
|
71
|
-
|
|
72
71
|
name = TAG_WITH
|
|
73
72
|
end = TAG_ENDWITH
|
|
74
73
|
node_class = WithNode
|
|
@@ -76,8 +75,6 @@ class WithTag(Tag):
|
|
|
76
75
|
def parse(self, stream: TokenStream) -> Node:
|
|
77
76
|
token = stream.eat(TOKEN_TAG)
|
|
78
77
|
args = KeywordArgument.parse(self.env, stream.into_inner(tag=token))
|
|
79
|
-
|
|
80
|
-
# Parse the block
|
|
81
78
|
block = get_parser(self.env).parse_block(stream, (TAG_ENDWITH, TOKEN_EOF))
|
|
82
79
|
stream.expect(TOKEN_TAG, value=TAG_ENDWITH)
|
|
83
80
|
return self.node_class(token, args=args, block=block)
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{python_liquid-2.2.0 → python_liquid-2.2.2}/liquid/builtin/loaders/caching_file_system_loader.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|