fasthx.core_decorators
hx(render, *, no_data=False, render_error=None, stream=False)
Decorator that converts a FastAPI route's return value into HTML if the request was an HTMX one.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
render
|
|
The render function converting the route's return value to HTML. |
required |
no_data
|
|
If set, the route will only accept HTMX requests. |
False
|
render_error
|
|
Optional render function for handling exceptions raised by the decorated route.
If not |
None
|
stream
|
|
If set, the route will stream the response. |
False
|
Returns:
| Type | Description |
|---|---|
|
The rendered HTML for HTMX requests, otherwise the route's unchanged return value. |
Source code in fasthx/core_decorators.py
page(render, *, render_error=None, stream=False)
Decorator that converts a FastAPI route's return value into HTML.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
render
|
|
The render function converting the route's return value to HTML. |
required |
render_error
|
|
Optional render function for handling exceptions raised by the decorated route.
If not |
None
|
stream
|
|
If set, the route will stream the response. |
False
|
Source code in fasthx/core_decorators.py
154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 | |