Make templates more faithful to the original file in terms of indentation, newlines, no deserialisation of things like < or >. More test coverage
This commit is contained in:
parent
3d53d4fb30
commit
49fee7afe4
12 changed files with 579 additions and 52 deletions
|
|
@ -31,6 +31,7 @@ from jinjaturtle.core import (
|
|||
def render_template(template: str, variables: dict[str, Any]) -> str:
|
||||
"""Render a Jinja2 template with variables."""
|
||||
env = Environment(undefined=StrictUndefined)
|
||||
env.filters["to_json"] = lambda value, **kwargs: json.dumps(value, **kwargs)
|
||||
jinja_template = env.from_string(template)
|
||||
return jinja_template.render(variables)
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue