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:
Miguel Jacq 2026-06-20 15:28:48 +10:00
parent 3d53d4fb30
commit 49fee7afe4
Signed by: mig5
GPG key ID: 03906B4110AAD3B8
12 changed files with 579 additions and 52 deletions

View file

@ -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)