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

_ensure_chirp_ui_filters 1 None
Ensure chirp-ui required filters exist when chirp-ui templates are loadable. W…
def _ensure_chirp_ui_filters(env: Environment) -> None

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

When chirp adds chirp-ui's PackageLoader, those templates require bem, field_errors, html_attrs, validate_variant, validate_variant_block, validate_size, icon. This fallback adds any missing filters so the env is self-consistent. 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.
def render_fragment(env: Environment, frag: Fragment) -> str
Parameters
Name Type Description
env Environment
frag Fragment
Returns
str