Skip to content

Commit 36c409d

Browse files
committed
Release 0.4.1: Jinja2 templates render forms without |safe
SafeHTML.__html__() is a method returning the HTML string, satisfying MarkupSafe's escape() protocol. Jinja2 auto-escaping recognizes form.render() output as trusted HTML.
1 parent 2db16a3 commit 36c409d

3 files changed

Lines changed: 17 additions & 2 deletions

File tree

CHANGELOG/0.4.1.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
## AirForm 0.4.1: Fix __html__ for Jinja2 compatibility
2+
3+
`SafeHTML.__html__` is now a method that returns the HTML string, not a boolean attribute. Jinja2 and MarkupSafe call `obj.__html__()` and expect a string back. The 0.4.0 release had `__html__ = True`, which raised `TypeError: 'bool' object is not callable` when Jinja2 tried to auto-escape form output.
4+
5+
```sh
6+
uv add AirForm --upgrade
7+
```
8+
9+
### What's fixed
10+
11+
- **`{{ form.render() }}` works in Jinja2 templates without `|safe`.** MarkupSafe's `escape()` calls `obj.__html__()` to get trusted HTML. The method returns `str(self)`, satisfying both Jinja2/MarkupSafe (calls it) and Air's tag system (checks `hasattr`).
12+
13+
### Contributors
14+
15+
[@audreyfeldroy](https://github.com/audreyfeldroy) (Audrey M. Roy Greenfeld) built this release. Bug discovered by the feldroy.com integration in a parallel session.

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ build-backend = "hatchling.build"
44

55
[project]
66
name = "AirForm"
7-
version = "0.4.0"
7+
version = "0.4.1"
88
description = "Pydantic-native form validation and rendering. Define a model, get a validated, rendered HTML form. Works with or without Air web framework."
99
readme = "README.md"
1010
authors = [

uv.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)