Classes
FunctionBlockParsingMixin
10
▼
Mixin for parsing function blocks.
Host attributes and cross-mixin dependencies are declared via i…
FunctionBlockParsingMixin
10
▼
Mixin for parsing function blocks.
Host attributes and cross-mixin dependencies are declared via inline TYPE_CHECKING blocks. Inherits block stack management from BlockStackMixin.
Methods
Internal Methods 10 ▼
_parse_type_annotation
0
str | None
▼
Parse an optional type annotation after a parameter name.
Called when the curr…
_parse_type_annotation
0
str | None
▼
def _parse_type_annotation(self) -> str | None
Parse an optional type annotation after a parameter name.
Called when the current token is COLON (indicating a type follows). Consumes the colon and type expression tokens, returning the raw annotation string.
Grammar::
type_expr := NAME [ '|' NAME ]* [ '[' type_expr (',' type_expr)* ']' ]
Handles:str, int, list, str | None,
dict[str, int], MyModel.
Returns
str | None
Raw annotation string, or None if no colon follows.
_parse_type_annotation_inner
0
str
▼
Parse a single type inside brackets (for generic parameters).
_parse_type_annotation_inner
0
str
▼
def _parse_type_annotation_inner(self) -> str
Returns
str
Type string (e.g. "str", "str | None").
_parse_def
0
Def
▼
Parse {% def name(args) %}...{% end %} or {% enddef %.
Kida functions with tru…
_parse_def
0
Def
▼
def _parse_def(self) -> Def
Parse {% def name(args) %}...{% end %} or {% enddef %.
Kida functions with true lexical scoping (can access outer scope). Uses stack-based parsing for proper nested block handling.
Supports optional type annotations on parameters::
{% def card(title: str, items: list, footer: str | None = None) %}
...
{% end %}
Returns
Def
_parse_region
0
Region
▼
Parse {% region name(params) %}...{% end %} or {% endregion %}.
_parse_region
0
Region
▼
def _parse_region(self) -> Region
Returns
Region
_parse_call
0
CallBlock
▼
Parse {% call name(args) %}body{% end %} or {% endcall %.
Call a function/def …
_parse_call
0
CallBlock
▼
def _parse_call(self) -> CallBlock
Parse {% call name(args) %}body{% end %} or {% endcall %.
Call a function/def with body content that fills {% slot %}. Supports named slots: {% slot name %}...{% end %} assigns to slot name; content outside slot blocks goes to default.
Returns
CallBlock
_parse_call_body
0
dict[str, Sequence[Node]]
▼
Parse call block body into slots dict.
When {% slot name %}...{% end %} appear…
_parse_call_body
0
dict[str, Sequence[Node]]
▼
def _parse_call_body(self) -> dict[str, Sequence[Node]]
Parse call block body into slots dict.
When {% slot name %}...{% end %} appears, content goes to slots[name]. Other content goes to slots["default"].
Returns
dict[str, Sequence[Node]]
_parse_let_bindings
0
list[tuple[str, Expr]]
▼
Parse let:name=expr pairs for scoped slot bindings (def-side).
Grammar::
l…
_parse_let_bindings
0
list[tuple[str, Expr]]
▼
def _parse_let_bindings(self) -> list[tuple[str, Expr]]
Parse let:name=expr pairs for scoped slot bindings (def-side).
Grammar:: let_binding := 'let' ':' NAME '=' expression let_bindings := let_binding (',' let_binding)*
Returns
list[tuple[str, Expr]]
List of (name, expr) tuples.
_parse_let_params
0
list[str]
▼
Parse let:name declarations for scoped slot params (call-site).
Grammar::
…
_parse_let_params
0
list[str]
▼
def _parse_let_params(self) -> list[str]
Parse let:name declarations for scoped slot params (call-site).
Grammar:: let_param := 'let' ':' NAME let_params := let_param (',' let_param)*
Returns
list[str]
List of parameter names.
_parse_slot
0
Slot | SlotBlock
▼
Parse {% slot %} or {% slot name %} — context-dependent.
Inside {% call %}: pa…
_parse_slot
0
Slot | SlotBlock
▼
def _parse_slot(self) -> Slot | SlotBlock
Parse {% slot %} or {% slot name %} — context-dependent.
Inside {% call %}: parse {% slot name %}...{% end %} as SlotBlock. With scoped params: {% slot name let:item, let:index %}...{% end %} Inside {% def %}: parse self-closing {% slot %} or {% slot name %} as Slot. With scoped bindings: {% slot name let:item=expr, let:index=loop.index %}
Returns
Slot | SlotBlock
_parse_yield
0
Slot
▼
Parse {% yield %} or {% yield name %} — always a render reference.
Unlike {% s…
_parse_yield
0
Slot
▼
def _parse_yield(self) -> Slot
Parse {% yield %} or {% yield name %} — always a render reference.
Unlike {% slot %}, which becomes a SlotBlock inside {% call %} blocks, {% yield %} always produces a Slot node. This makes it safe to use inside nested {% call %} blocks when forwarding the enclosing def's caller slots.
Returns
Slot