Layout chain rendering with HX-Target-aware depth.
The renderer composes nested layouts inside-out using kida's
render_with_blocks(). The HX-Targetheader determines how
deep to render — only the layouts below the targeted element are
rendered, preserving the outer shell on the client.
pages.renderer
| Name | Type | Default | Description |
|---|---|---|---|
type
|
|
— | |
qualified_name
|
|
— | |
element_type
|
|
— | |
description
|
|
— | |
source_file
|
|
— | |
line_number
|
|
— | |
is_autodoc
|
|
— | |
autodoc_element
|
|
— | |
_autodoc_template
|
|
— | |
_autodoc_url_path
|
|
— | |
_autodoc_page_type
|
|
— | |
title
|
|
— | |
doc_content_hash
|
|
— |
Symbols on this page
_omit_outer_layout_targets
function
def _omit_outer_layout_targets(*, fragment_target_registry: FragmentTargetRegistry | None, htmx_target: str | None) -> frozenset[str]
Return registered targets that should omit the matched outer layout.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
fragment_target_registry
|
FragmentTargetRegistry | None
|
— | |
htmx_target
|
str | None
|
— |
render_with_layouts
function
def render_with_layouts(env: Environment, *, layout_chain: LayoutChain, page_html: str, context: dict[str, Any], htmx_target: str | None = None, is_history_restore: bool = False, fragment_target_registry: FragmentTargetRegistry | None = None) -> str
Render page content wrapped in its layout chain.
UsesHX-Targetto determine rendering depth:
- No target (full page load or history restore): render all layouts nested, innermost first.
- Target matches a replace outlet or omit target: skip the matched outer layout and render any descendant layouts below it.
- Target matches an ordinary layout target: render the matched layout and any descendants below it.
- Target matches no layout: return page HTML as-is (fragment).
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
env
|
Environment
|
— | The kida ``Environment`` for loading layout templates. |
layout_chain
|
LayoutChain
|
— | Sequence of layouts from root (outermost) to deepest (closest to the page). |
page_html
|
str
|
— | Pre-rendered page content HTML. |
context
|
dict[str, Any]
|
— | Merged context variables for layout templates. |
htmx_target
|
str | None
|
None
|
Value of ``HX-Target`` header, or ``None``. |
is_history_restore
|
bool
|
False
|
Whether this is an htmx history restore. |
fragment_target_registry
|
FragmentTargetRegistry | None
|
None
|
Optional registry for targets that must skip the matched outer filesystem layout during boosted navigation. |
View source · /home/runner/work/chirp/chirp/site/../src/chirp/pages/renderer.py:1