Module

environment.filters._string

String manipulation filters for Kida templates.

Functions

_filter_capitalize 1 str
Capitalize first character.
def _filter_capitalize(value: str) -> str
Parameters
Name Type Description
value str
Returns
str
_filter_lower 1 str
Convert to lowercase.
def _filter_lower(value: str) -> str
Parameters
Name Type Description
value str
Returns
str
_filter_upper 1 str
Convert to uppercase.
def _filter_upper(value: str) -> str
Parameters
Name Type Description
value str
Returns
str
_filter_title 1 str
Title case.
def _filter_title(value: str) -> str
Parameters
Name Type Description
value str
Returns
str
_filter_trim 2 str
Strip whitespace or specified characters.
def _filter_trim(value: str, chars: str | None = None) -> str
Parameters
Name Type Description
value str

String to trim

chars str | None

Optional characters to strip (default: whitespace)

Default:None
Returns
str
_filter_replace 4 str
Replace occurrences.
def _filter_replace(value: str, old: str, new: str, count: int | str | None = -1) -> str
Parameters
Name Type Description
value str
old str
new str
count int | str | None Default:-1
Returns
str
_filter_truncate 5 str
Truncate string to specified length.
def _filter_truncate(value: str, length: int = 255, killwords: bool = False, end: str = '...', leeway: int | None = None) -> str
Parameters
Name Type Description
value str

String to truncate

length int

Maximum length including end marker

Default:255
killwords bool

If False (default), truncate at word boundary; if True, cut mid-word

Default:False
end str

String to append when truncated (default: "...")

Default:'...'
leeway int | None

Allow slightly longer strings before truncating (Jinja2 compat, ignored)

Default:None
Returns
str
_filter_center 2 str
Center string in width.
def _filter_center(value: str, width: int = 80) -> str
Parameters
Name Type Description
value str
width int Default:80
Returns
str
_filter_indent 3 str
Indent text lines.
def _filter_indent(value: str, width: int = 4, first: bool = False) -> str
Parameters
Name Type Description
value str
width int Default:4
first bool Default:False
Returns
str
_filter_wordwrap 3 str
Wrap text at width.
def _filter_wordwrap(value: str, width: int = 79, break_long_words: bool = True) -> str
Parameters
Name Type Description
value str
width int Default:79
break_long_words bool Default:True
Returns
str
_filter_format 3 str
Format string with args/kwargs. Uses str.format() — {} placeholders, not %.
def _filter_format(value: str, *args: Any, **kwargs: Any) -> str
Parameters
Name Type Description
value str
*args Any
**kwargs Any
Returns
str
_filter_slug 1 str
Convert text to URL-safe slug (lowercase, hyphens, ASCII-only).
def _filter_slug(value: Any) -> str
Parameters
Name Type Description
value Any
Returns
str
_filter_pluralize 2 str
Django-style pluralization suffix.
def _filter_pluralize(value: Any, suffix: str = 's') -> str
Parameters
Name Type Description
value Any
suffix str Default:'s'
Returns
str
_filter_wordcount 1 int
Count words in a string.
def _filter_wordcount(value: str) -> int
Parameters
Name Type Description
value str
Returns
int