Module

pages.renderer

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.

Functions

_omit_outer_layout_targets 2 frozenset[str]
Return registered targets that should omit the matched outer layout.
def _omit_outer_layout_targets(*, fragment_target_registry: FragmentTargetRegistry | None, htmx_target: str | None) -> frozenset[str]
Parameters
Name Type Description
fragment_target_registry FragmentTargetRegistry | None
htmx_target str | None
Returns
frozenset[str]
render_with_layouts 7 str
Render page content wrapped in its layout chain. Uses ``HX-Target`` to determi…
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 Description
env Environment

The kidaEnvironmentfor 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

Value ofHX-Target header, or None.

Default:None
is_history_restore bool

Whether this is an htmx history restore.

Default:False
fragment_target_registry FragmentTargetRegistry | None

Optional registry for targets that must skip the matched outer filesystem layout during boosted navigation.

Default:None
Returns
str