hx()
Decorator that converts a FastAPI route's return value into HTML if the request was an HTMX one.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
render |
HTMLRenderer[T]
|
The render function converting the route's return value to HTML. |
required |
no_data |
bool
|
If set, the route will only accept HTMX requests. |
False
|
Returns:
Type | Description |
---|---|
Callable[[MaybeAsyncFunc[P, T]], Callable[P, Coroutine[None, None, T | Response]]]
|
The rendered HTML for HTMX requests, otherwise the route's unchanged return value. |