Functions
_minimal_kida_env
0
Environment
▼
Create a bare kida Environment for inline template rendering.
Used when no tem…
_minimal_kida_env
0
Environment
▼
def _minimal_kida_env() -> Environment
Create a bare kida Environment for inline template rendering.
Used when no template_dir is configured but an InlineTemplate needs to be rendered (prototyping without any file templates).
Returns
Environment
_html_response
2
Response
▼
Build a text/html response with explicit render intent.
_html_response
2
Response
▼
def _html_response(body: str, *, intent: RenderIntent) -> Response
Parameters
| Name | Type | Description |
|---|---|---|
body |
str |
|
intent |
RenderIntent |
Returns
Response
_fragment_response
1
Response
▼
Build a text/html response for fragment-returning endpoints.
_fragment_response
1
Response
▼
def _fragment_response(body: str) -> Response
Parameters
| Name | Type | Description |
|---|---|---|
body |
str |
Returns
Response
_require_kida_env
2
Environment
▼
Raise ConfigurationError if kida_env is None (template return types need it).
_require_kida_env
2
Environment
▼
def _require_kida_env(kida_env: Environment | None, return_type: str) -> Environment
Parameters
| Name | Type | Description |
|---|---|---|
kida_env |
Environment | None |
|
return_type |
str |
Returns
Environment
_with_current_path_in_context
2
Template | Page | Layout…
▼
Return *value* with ``current_path`` merged into context (copy-on-write).
Avoi…
_with_current_path_in_context
2
Template | Page | Layout…
▼
def _with_current_path_in_context(value: Template | Page | LayoutPage, request: Request | None) -> Template | Page | LayoutPage
Return value withcurrent_pathmerged into context (copy-on-write).
Avoids mutating a sharedcontextdict when handlers reuse a frozen
Template/Page/LayoutPageacross requests.
Template/Page/LayoutPage use custom __init__— construct fresh
instances instead ofdataclasses.replace (which does not pass name).
Parameters
| Name | Type | Description |
|---|---|---|
value |
Template | Page | LayoutPage |
|
request |
Request | None |
Returns
Template | Page | LayoutPage
_render_composition
6
Response
▼
Shared 5-step pipeline: shell updates → plan → execute → serialize → response.
…
_render_composition
6
Response
▼
def _render_composition(composition: PageComposition, request: Request | None, fragment_target_registry: FragmentTargetRegistry | None, kida_env: Environment, validate_blocks: bool, oob_registry: OOBRegistry | None) -> Response
Shared 5-step pipeline: shell updates → plan → execute → serialize → response.
SetsVary: HX-Requestbecause the response varies depending on
whether the request is a full-page load or an htmx fragment request.
Without this, HTTP caches may serve a cached fragment to a full-page
request (or vice versa).
Parameters
| Name | Type | Description |
|---|---|---|
composition |
PageComposition |
|
request |
Request | None |
|
fragment_target_registry |
FragmentTargetRegistry | None |
|
kida_env |
Environment |
|
validate_blocks |
bool |
|
oob_registry |
OOBRegistry | None |
Returns
Response
_set_layout_debug_from_plan
2
None
▼
Set layout debug metadata for LayoutDebugMiddleware when config.debug.
_set_layout_debug_from_plan
2
None
▼
def _set_layout_debug_from_plan(plan: Any, request: Request | None) -> None
Parameters
| Name | Type | Description |
|---|---|---|
plan |
Any |
|
request |
Request | None |
negotiate
6
Response | StreamingResp…
▼
Convert a route handler's return value to a Response.
Dispatch order:
1. ``Re…
negotiate
6
Response | StreamingResp…
▼
def negotiate(value: Any, *, kida_env: Environment | None = None, request: Request | None = None, validate_blocks: bool = False, oob_registry: OOBRegistry | None = None, fragment_target_registry: FragmentTargetRegistry | None = None) -> Response | StreamingResponse | SSEResponse
Convert a route handler's return value to a Response.
Dispatch order:
Response-> pass throughRedirect-> 302 with Location headerFormAction-> htmx: fragments or HX-Redirect; non-htmx: 303Template-> render via kida -> ResponseFragment-> render block via kida -> ResponsePage-> Template or Fragment based on request headersAction-> empty Response + optional HX headersValidationError-> Fragment + 422 + optional HX-RetargetOOB-> primary + hx-swap-oob fragmentsStream-> kida render_stream() -> StreamingResponse(async sources resolved concurrently)TemplateStream-> kida render_stream_async() -> StreamingResponseSuspense-> shell + deferred OOB blocks -> StreamingResponse(first paint instant, blocks fill in)EventStream-> SSEResponse (handler dispatches to SSE)str-> 200, text/htmlbytes-> 200, application/octet-streamdict/list-> 200, application/json(value, int)-> negotiate value, override status(value, int, dict)-> negotiate value, override status + headers
Parameters
| Name | Type | Description |
|---|---|---|
value |
Any |
|
kida_env |
Environment | None |
Default:None
|
request |
Request | None |
Default:None
|
validate_blocks |
bool |
Default:False
|
oob_registry |
OOBRegistry | None |
Default:None
|
fragment_target_registry |
FragmentTargetRegistry | None |
Default:None
|
Returns
Response | StreamingResponse | SSEResponse