-
-
Notifications
You must be signed in to change notification settings - Fork 93
Description
Summary
Add a strict BaseTag.from_jinja() helper that renders a Jinja template to HTML and immediately converts it into real Air Tags nodes via BaseTag.from_html.
This should be strict-only: invalid HTML must raise, matching BaseTag.from_html behavior.
Motivation
Mixing Air Tags and Jinja is a valid use case, but embedding rendered Jinja output as a raw HTML string (SafeStr / trusted HTML) inside an Air Tags tree makes that subtree opaque to anything that expects real tags (tree transforms, structure-based features, future tooling, etc.).
We already have a non-strict path that returns template output as a string for insertion into tags. That was implemented in PR #981 and closed issue #231. This request is specifically for the strict option that converts template output into actual Air Tags nodes.
Proposed API
BaseTag.from_jinja(template, /, **context) -> BaseTagBehavior:
- Render the
Jinjatemplate to an HTML string. - Parse using
BaseTag.from_html(rendered_html). - Return the resulting Air Tags tree.
Notes:
- No non-strict mode here. If parsing fails, raise (same as
BaseTag.from_html).
References
- Existing non-strict behavior: PR Make Jinja render from within air tags #981
- Related issue (already closed by the PR above): Jinja renderer not rendering from within Air Tags #231
Acceptance criteria
BaseTag.from_jinja()exists and is documented.- Tests cover:
- valid fragment output
- full document output
- invalid HTML raises (no fallback)