holm.typing
APIFactory = PlainAPIFactory | RenderingAPIFactory
module-attribute
APIRouter factory definition.
It is a callable that optionally accepts a HTMY instance as an argument to make sure
the same renderer is used throughout the application if the API does HTML rendering.
Otherwise the argument can be omitted.
ErrorHandlerMapping = Mapping[type[Exception] | int, FastAPIErrorHandler]
module-attribute
Mapping type whose keys are exception types or HTTP status codes, and the corresponding values are FastAPI error handlers.
Layout = SyncLayout | PropsOnlySyncLayout | AsyncLayout | PropsOnlyAsyncLayout
module-attribute
Layout type definition.
A layout is a callable that expects a single positional argument the component or data returned
by the wrapped layout or page, and returns the properties for its wrapper layout. The root layout
must always return a Component.
LayoutFactory = Callable[[Any], Any | Coroutine[None, None, Any]]
module-attribute
A layout factory is a sync or async callable that expects a single argument (the layout's properties) and returns the properties for its wrapper layout.
The root layout factory must always return a htmy Component.
Page = FastAPIDependency[Any]
module-attribute
FastAPI page dependency.
A page may return either the properties for the layout that wraps it (for example a Component)
or a FastAPI Response.
If the page is not wrapped by a layout and it doesn't return a Response,
then it must return a Component.
PlainAPIFactory = Callable[[], APIRouter]
module-attribute
Plain, non-rendering APIRouter factory type definition.
PropsOnlyAsyncLayout = Callable[[Any], Coroutine[Any, Any, Any]]
module-attribute
Async layout that only accepts a single position argument, the layout's properties.
PropsOnlySyncLayout = Callable[[Any], Any]
module-attribute
Sync layout that only accepts a single position argument, the layout's properties.
RenderingAPIFactory = Callable[[HTMY], APIRouter]
module-attribute
Rendering APIRouter factory type definition.
TextToLayoutConverter = Callable[[str], Layout]
module-attribute
Type alias for functions that convert plain string to a Layout function.
The easiest way to create a TextToLayoutConverter is to create a wrapper
around holm.utils.snippet_to_layout.