Module

templating.integration

Kida environment setup and app binding.

Creates a kida Environment from chirp's AppConfig and binds user-registered filters and globals. The environment is created once during App._freeze() and passed through the request pipeline.

Functions

_is_chirp_ui_filter_override 2 bool
True when *func* is chirp-ui's implementation replacing chirp stubs for the UI …
def _is_chirp_ui_filter_override(name: str, func: Callable[..., Any]) -> bool

True when func is chirp-ui's implementation replacing chirp stubs for the UI kit.

Parameters
Name Type Description
name str
func Callable[..., Any]
Returns
bool
_ensure_chirp_ui_filters 1 None
Ensure chirp-ui required filters and globals exist when chirp-ui templates are …
def _ensure_chirp_ui_filters(env: Environment) -> None

Ensure chirp-ui required filters and globals exist when chirp-ui templates are loadable.

When chirp adds chirp-ui's PackageLoader, those templates require a set of filters and globals to compile. This fallback mirrors the surface registered bychirp_ui.register_filtersso the env is self-consistent even when the app did not calluse_chirp_ui. Kept name-by-name (rather than calling chirp-ui's own registrar) because Kida'sEnvironmentdoesn't implement the fullTemplateFilterAppprotocol. See docs/rfcs/001-component-filter-contract.md.

Parameters
Name Type Description
env Environment
create_environment 4 Environment
Create a kida Environment from app configuration. Called once during ``App._fr…
def create_environment(config: AppConfig, filters: dict[str, Callable[..., Any]], globals_: dict[str, Any], plugin_loaders: list | None = None) -> Environment

Create a kida Environment from app configuration.

Called once duringApp._freeze(). The returned environment is immutable for the lifetime of the app.

Supports multiple template directories viaconfig.component_dirs for component libraries, partials, and shared templates. Extra loaders (CMS, DB, state) are tried first when configured.

Parameters
Name Type Description
config AppConfig
filters dict[str, Callable[..., Any]]
globals_ dict[str, Any]
plugin_loaders list | None Default:None
Returns
Environment
render_template 2 str
Render a full template to string.
def render_template(env: Environment, tpl: Template) -> str
Parameters
Name Type Description
env Environment
tpl Template
Returns
str
render_fragment 2 str
Render a named block from a template to string. Raises ``BlockNotFoundError`` …
def render_fragment(env: Environment, frag: Fragment) -> str

Render a named block from a template to string.

RaisesBlockNotFoundError (a KeyErrorsubclass) when the named block does not exist in the template. Unifies the error contract across both OOB pipelines — region updates (PR #90) andOOB(...)return values both surface the same exception type with the same message shape.

Parameters
Name Type Description
env Environment
frag Fragment
Returns
str