Module

templating.fragment_target_registry

App-level fragment target registry for HTMX content-region block selection.

Maps target IDs (e.g.page-root) to fragment_block config. When HX-Target matches a registered target, Chirp uses the registry's fragment_block instead of composition.page_block. Apps can group related targets into a page shell contract so app-level layout expectations are explicit and contract-checkable. The registry is mutable during setup and frozen at runtime.

Classes

PageShellTarget 5
A single target participating in a page shell contract.

A single target participating in a page shell contract.

Attributes

Name Type Description
target_id str
fragment_block str
triggers_shell_update bool
required bool
description str
PageShellContract 4
Named group of fragment targets defining an app shell contract.

Named group of fragment targets defining an app shell contract.

Attributes

Name Type Description
name str
targets tuple[PageShellTarget, ...]
description str

Methods

required_fragment_blocks 0 frozenset[str]
property
def required_fragment_blocks(self) -> frozenset[str]
Returns
frozenset[str]
FragmentTargetConfig 5
Block config for a single fragment target. **Layers (see UI layers guide):** targets that swap **p…

Block config for a single fragment target.

Layers (see UI layers guide): targets that swap page content inside #page-content may still set triggers_shell_updateso shell regions (topbarshell_actions, title, etc.) refresh via OOB after the primary swap.

fragment_block: Block to render when HX-Target matches (e.g. page_root_inner). triggers_shell_update: When True, this swap participates in shell negotiation (e.g.shell_actionsOOB). Use False for narrow in-page swaps (e.g.#page-content-inner) that must not refresh the app shell.

Attributes

Name Type Description
fragment_block str
triggers_shell_update bool
contract_name str | None
required bool
description str
FragmentTargetRegistry 11
App-level registry mapping target IDs to fragment block config. Mutable during setup, frozen at ru…

App-level registry mapping target IDs to fragment block config.

Mutable during setup, frozen at runtime (same lifecycle as routes).

Attributes

Name Type Description
_targets dict[str, FragmentTargetConfig]
_contracts dict[str, PageShellContract]
_frozen bool

Methods

registered_targets 0 frozenset[str]
property
def registered_targets(self) -> frozenset[str]
Returns
frozenset[str]
registered_contracts 0 tuple[PageShellContract,…
property
def registered_contracts(self) -> tuple[PageShellContract, ...]
Returns
tuple[PageShellContract, ...]
required_fragment_blocks 0 frozenset[str]
property
def required_fragment_blocks(self) -> frozenset[str]
Returns
frozenset[str]
register 6
def register(self, target_id: str, *, fragment_block: str, triggers_shell_update: bool = True, contract_name: str | None = None, required: bool = False, description: str = '') -> None
Parameters
Name Type Description
target_id
fragment_block
triggers_shell_update Default:True
contract_name Default:None
required Default:False
description Default:''
register_contract 1
Register a named page shell contract and all of its targets.
def register_contract(self, contract: PageShellContract) -> None
Parameters
Name Type Description
contract
freeze 0
def freeze(self) -> None
get 1 FragmentTargetConfig | N…
def get(self, target_id: str) -> FragmentTargetConfig | None
Parameters
Name Type Description
target_id
Returns
FragmentTargetConfig | None
is_content_target 1 bool
Return True when target expects fragment response (not full page_block).
def is_content_target(self, target_id: str) -> bool
Parameters
Name Type Description
target_id
Returns
bool