Functions
bem
4
str
▼
Build chirpui BEM class string: chirpui-{block} chirpui-{block}--{variant} etc.
bem
4
str
▼
def bem(block: str, variant: str = '', modifier: str = '', cls: str = '') -> str
Build chirpui BEM class string: chirpui-{block} chirpui-{block}--{variant} etc.
Parameters
| Name | Type | Description |
|---|---|---|
block |
str |
|
variant |
str |
Default:''
|
modifier |
str |
Default:''
|
cls |
str |
Default:''
|
Returns
str
attr
2
str | Markup
▼
Output an HTML attribute when value is truthy, else empty string.
Shorthand fo…
attr
2
str | Markup
▼
def attr(value: Any, name: str) -> str | Markup
Output an HTML attribute when value is truthy, else empty string.
Shorthand for optional attributes without{% if %}blocks.
Parameters
| Name | Type | Description |
|---|---|---|
value |
Any |
|
name |
str |
Returns
str | Markup
_serialize_attr_value
1
str
▼
Serialize attribute value into a stable string.
_serialize_attr_value
1
str
▼
def _serialize_attr_value(value: Any) -> str
Parameters
| Name | Type | Description |
|---|---|---|
value |
Any |
Returns
str
html_attrs
1
str | Markup
▼
Render HTML attributes from mapping or legacy raw string.
Contract:
- ``dict``…
html_attrs
1
str | Markup
▼
def html_attrs(value: Any) -> str | Markup
Render HTML attributes from mapping or legacy raw string.
Contract:
dict/Mapping: escaped, deterministic HTML attributesstr/Markup: pass through (legacy compatibility)None/False: no output
Mapping values follow HTML attribute semantics:
Truerenders as a valueless attribute (e.g.disabled)False/Noneare omitted- other values are escaped and rendered as
key="value"
Parameters
| Name | Type | Description |
|---|---|---|
value |
Any |
Returns
str | Markup
field_errors
2
list[str]
▼
Extract validation errors for a single form field.
Safely navigates a ``{field…
field_errors
2
list[str]
▼
def field_errors(errors: Any, field_name: str) -> list[str]
Extract validation errors for a single form field.
Safely navigates a{field: [messages]}dict, returning an
empty list when errors is None, missing, or the field has no
errors.
Parameters
| Name | Type | Description |
|---|---|---|
errors |
Any |
|
field_name |
str |
Returns
list[str]
qs
2
str
▼
Append query-string parameters to a URL path.
Omits parameters whose values ar…
qs
2
str
▼
def qs(base: str, **params: Any) -> str
Append query-string parameters to a URL path.
Omits parameters whose values are falsy (None, "", 0, False) so callers can pass optional filters without manual guards.
Parameters
| Name | Type | Description |
|---|---|---|
base |
str |
|
**params |
Any |
Returns
str
timeago
1
str
▼
Convert a unix timestamp to a human-readable relative time.
timeago
1
str
▼
def timeago(unix_ts: int | float) -> str
Parameters
| Name | Type | Description |
|---|---|---|
unix_ts |
int | float |
Returns
str
pluralize
3
str
▼
Pluralize a word based on count.
pluralize
3
str
▼
def pluralize(count: int, singular: str, plural: str | None = None) -> str
Parameters
| Name | Type | Description |
|---|---|---|
count |
int |
|
singular |
str |
|
plural |
str | None |
Default:None
|
Returns
str
format_time
1
str
▼
Format a unix timestamp as ``HH:MM:SS`` (UTC).
format_time
1
str
▼
def format_time(unix_ts: float) -> str
Parameters
| Name | Type | Description |
|---|---|---|
unix_ts |
float |
Returns
str
url
2
str
▼
Safelist URL for href attributes. Uses Kida's url_is_safe.
Returns the URL if …
url
2
str
▼
def url(value: str, fallback: str = '#') -> str
Safelist URL for href attributes. Uses Kida's url_is_safe.
Returns the URL if the scheme is safe (http, https, relative), otherwise returns fallback. Use when building href from user or external data.
Parameters
| Name | Type | Description |
|---|---|---|
value |
str |
|
fallback |
str |
Default:'#'
|
Returns
str
island_props
1
Markup
▼
Serialize a value for safe use in ``data-island-props``.
Returns HTML-escaped …
island_props
1
Markup
▼
def island_props(value: Any) -> Markup
Serialize a value for safe use indata-island-props.
Returns HTML-escaped JSON as Markup so templates can embed props without manual escaping:
<div data-island-props="{{ props | island_props }}"></div>
Parameters
| Name | Type | Description |
|---|---|---|
value |
Any |
Returns
Markup
island_attrs
6
Markup
▼
Build a safe island mount attribute string.
Designed for framework-agnostic mo…
island_attrs
6
Markup
▼
def island_attrs(name: str, props: Any | None = None, *, mount_id: str | None = None, version: str = '1', src: str | None = None, cls: str = '') -> Markup
Build a safe island mount attribute string.
Designed for framework-agnostic mount roots:
<div{{ island_attrs("editor", props=state, mount_id="editor-root") }}>
...
</div>
Parameters
| Name | Type | Description |
|---|---|---|
name |
str |
|
props |
Any | None |
Default:None
|
mount_id |
str | None |
Default:None
|
version |
str |
Default:'1'
|
src |
str | None |
Default:None
|
cls |
str |
Default:''
|
Returns
Markup
primitive_attrs
6
Markup
▼
Build island attributes with primitive metadata conventions.
primitive_attrs
6
Markup
▼
def primitive_attrs(primitive: str, props: dict[str, Any] | None = None, *, mount_id: str | None = None, version: str = '1', src: str | None = None, cls: str = '') -> Markup
Parameters
| Name | Type | Description |
|---|---|---|
primitive |
str |
|
props |
dict[str, Any] | None |
Default:None
|
mount_id |
str | None |
Default:None
|
version |
str |
Default:'1'
|
src |
str | None |
Default:None
|
cls |
str |
Default:''
|
Returns
Markup