Module

nodes.control_flow

Control flow nodes for Kida AST.

Classes

If 4 ▼
Conditional: {% if cond %}...{% elif cond %}...{% else %}...{% end %}

Conditional: {% if cond %}...{% elif cond %}...{% else %}...{% end %}

Attributes

Name Type Description
test Expr —
body Sequence[Node] —
elif_ Sequence[tuple[Expr, Sequence[Node]]] —
else_ Sequence[Node] —
For 6 ▼
For loop: {% for x in items %}...{% empty %}...{% end %}

For loop: {% for x in items %}...{% empty %}...{% end %}

Attributes

Name Type Description
target Expr —
iter Expr —
body Sequence[Node] —
empty Sequence[Node] —
recursive bool —
test Expr | None —
AsyncFor 5 ▼
Async for loop: {% async for x in async_items %}...{% end %}

Async for loop: {% async for x in async_items %}...{% end %}

Attributes

Name Type Description
target Expr —
iter Expr —
body Sequence[Node] —
empty Sequence[Node] —
test Expr | None —
While 2 ▼
While loop: {% while cond %}...{% end %}

While loop: {% while cond %}...{% end %}

Attributes

Name Type Description
test Expr —
body Sequence[Node] —
Match 2 ▼
Pattern matching: {% match expr %}{% case pattern [if guard] %}...{% end %}

Pattern matching: {% match expr %}{% case pattern [if guard] %}...{% end %}

Attributes

Name Type Description
subject Expr | None —
cases Sequence[tuple[Expr, Expr | None, Sequence[Node]]] —
Break 0 ▼
Break out of loop: {% break %}

Break out of loop: {% break %}

Continue 0 ▼
Skip to next iteration: {% continue %}

Skip to next iteration: {% continue %}

Try 3 ▼
Error boundary: {% try %}...{% fallback [error] %}...{% end %} Catches rendering errors in body an…

Error boundary: {% try %}...{% fallback [error] %}...{% end %}

Catches rendering errors in body and renders fallback content instead. If error_name is set, the caught exception is bound as a dict in the fallback scope with keys: message, type, template, line.

Attributes

Name Type Description
body Sequence[Node] —
fallback Sequence[Node] —
error_name str | None —