Added a page decorator and Jinja.page + run sync routes in threadpool #15
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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
.