dyngle 0.4.0__tar.gz → 0.4.1__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.
- {dyngle-0.4.0 → dyngle-0.4.1}/PKG-INFO +1 -1
- {dyngle-0.4.0 → dyngle-0.4.1}/dyngle/template.py +4 -2
- {dyngle-0.4.0 → dyngle-0.4.1}/pyproject.toml +1 -1
- {dyngle-0.4.0 → dyngle-0.4.1}/PACKAGE.md +0 -0
- {dyngle-0.4.0 → dyngle-0.4.1}/dyngle/__init__.py +0 -0
- {dyngle-0.4.0 → dyngle-0.4.1}/dyngle/__main__.py +0 -0
- {dyngle-0.4.0 → dyngle-0.4.1}/dyngle/command/__init__.py +0 -0
- {dyngle-0.4.0 → dyngle-0.4.1}/dyngle/command/run_command.py +0 -0
- {dyngle-0.4.0 → dyngle-0.4.1}/dyngle/error.py +0 -0
- {dyngle-0.4.0 → dyngle-0.4.1}/dyngle/expression.py +0 -0
- {dyngle-0.4.0 → dyngle-0.4.1}/dyngle/safe_path.py +0 -0
|
@@ -11,15 +11,17 @@ class Template:
|
|
|
11
11
|
|
|
12
12
|
template: str
|
|
13
13
|
|
|
14
|
-
def render(self, data: dict, expressions: dict = None) -> str:
|
|
14
|
+
def render(self, data: dict = None, expressions: dict = None) -> str:
|
|
15
15
|
"""Render the template with the provided data."""
|
|
16
|
+
data = data if data else {}
|
|
17
|
+
expressions = expressions if expressions else {}
|
|
16
18
|
resolver = partial(self._resolve, data=data, expressions=expressions)
|
|
17
19
|
return PATTERN.sub(resolver, self.template)
|
|
18
20
|
|
|
19
21
|
def _resolve(self, match, *, data: dict, expressions: dict):
|
|
20
22
|
"""Resolve a single name/path from the template."""
|
|
21
23
|
key = match.group(1).strip()
|
|
22
|
-
if
|
|
24
|
+
if key in expressions:
|
|
23
25
|
return expressions[key](data)
|
|
24
26
|
else:
|
|
25
27
|
parts = key.split('.')
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|