v0.2402.2
Changes
- Added a
page()
decorator for unconditionally rendering HTML (useful when a route needs to serve HTML for non-HTMX requests). - Added a
Jinja.page()
decorator, the Jinja2 implementation of the genericpage()
decorator. - Sync routes are now executed in a threadpool to avoid blocking the asyncio event loop.
- Added
Jinja.hx()
as the primary decorator for HTMX-serving routes for overall consistency in the library. At the same time,Jinja.__call__()
andJinja.template()
are now deprecated and will be removed in the future. JinjaContext.unpack_result()
can now handleNone
as well by converting it into an empty Jinja rendering context.- Typing improvements.
- Renamed
HTMXRenderer
toHTMLRenderer
.HTMXRenderer
is still importable as a deprecated alias ofHTMLRenderer
. - Updated the existing Jinja example to showcase the updated
Jinja
class. - Added a fully-working (although rather basic) custom rendering example.
- Updated the documentation.
Internals
A lot of internal code has been moved. If, for some reason you imported something directly from a module instead of the package, you will unfortunately need to update your imports. New package layout:
fasthx.core_decorators
: thehx()
andpage()
decorators can now be found here.- Jinja-related code has been moved from
fasthx.main
tofasthx.jinja
. get_hx_request()
andDependsHXRequest
are now infasthx.dependencies
.- All utility types have been moved from
fasthx.main
tofasthx.typing
. - The internal
_append_to_signature()
method was moved fromfasthx.main
tofasthx.utils
and renamed toappend_to_signature
. This method is still for internal use only.