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 generic page() 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__() and Jinja.template() are now deprecated and will be removed in the future.
JinjaContext.unpack_result() can now handle None as well by converting it into an empty Jinja rendering context.
Typing improvements.
Renamed HTMXRenderer to HTMLRenderer. HTMXRenderer is still importable as a deprecated alias of HTMLRenderer.
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: the hx() and page() decorators can now be found here.
Jinja-related code has been moved from fasthx.main to fasthx.jinja.
get_hx_request() and DependsHXRequest are now in fasthx.dependencies.
All utility types have been moved from fasthx.main to fasthx.typing.
The internal _append_to_signature() method was moved from fasthx.main to fasthx.utils and renamed to append_to_signature. This method is still for internal use only.
Notes
Tentatively bumped version to 0.2402.2, although putting so many (and important) changes in a patch release is not that user-friendly. I'm considering moving to semver and 1.0 at this point, or alternatively to 0.2403.0.
Changes
page()
decorator for unconditionally rendering HTML (useful when a route needs to serve HTML for non-HTMX requests).Jinja.page()
decorator, the Jinja2 implementation of the genericpage()
decorator.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.HTMXRenderer
toHTMLRenderer
.HTMXRenderer
is still importable as a deprecated alias ofHTMLRenderer
.Jinja
class.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.fasthx.main
tofasthx.jinja
.get_hx_request()
andDependsHXRequest
are now infasthx.dependencies
.fasthx.main
tofasthx.typing
._append_to_signature()
method was moved fromfasthx.main
tofasthx.utils
and renamed toappend_to_signature
. This method is still for internal use only.Notes
Tentatively bumped version to
0.2402.2
, although putting so many (and important) changes in a patch release is not that user-friendly. I'm considering moving to semver and1.0
at this point, or alternatively to0.2403.0
.