diff --git a/README.md b/README.md index d936eea..1efd0da 100644 --- a/README.md +++ b/README.md @@ -88,18 +88,15 @@ def render_user_list(result: list[dict[str, str]], *, context: dict[str, Any], r users = "".join(("")) return f"{lucky_number}\n{users}" - @app.get("/htmx-or-data") @hx(render_user_list) def htmx_or_data(random_number: DependsRandomNumber) -> list[dict[str, str]]: return [{"name": "Joe"}] - @app.get("/htmx-only") @hx(render_user_list, no_data=True) async def htmx_only(random_number: DependsRandomNumber) -> list[dict[str, str]]: return [{"name": "Joe"}] - ``` ## Dependencies diff --git a/docs/index.md b/docs/index.md index 74d2a71..1efd0da 100644 --- a/docs/index.md +++ b/docs/index.md @@ -64,11 +64,14 @@ def htmx_only() -> dict[str, list[dict[str, str]]]: Custom templating offers more flexibility than the built-in `Jinja` renderer by giving access to all dependencies of the decorated route to the renderer function: ```python -from typing import Annotated +from typing import Annotated, Any -from fastapi import Depends, FastAPI +from fastapi import Depends, FastAPI, Request from fasthx import hx +# Create the app. +app = FastAPI() + # Create a dependecy to see that its return value is available in the render function. def get_random_number() -> int: return 4 # Chosen by fair dice roll.