Skip to content

AirForm 0.4.1

Choose a tag to compare

@audreyfeldroy audreyfeldroy released this 21 Mar 05:44
· 5 commits to main since this release
v0.4.1
36c409d

AirForm 0.4.1: Fix html for Jinja2 compatibility

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.

uv add AirForm --upgrade

What's fixed

  • {{ 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).

Contributors

@audreyfeldroy (Audrey M. Roy Greenfeld) built this release. Bug discovered by the feldroy.com integration in a parallel session.