# functions

URL: /kida/api/nodes/functions/
Section: nodes
Description: Function definition and call nodes for Kida AST.

---

> For a complete page index, fetch /kida/llms.txt.

Open LLM text
(/kida/api/nodes/functions/index.txt)

Share with AI

Ask Claude
(https://claude.ai/new?q=Please%20help%20me%20understand%20this%20documentation%3A%20%2Fkida%2Fapi%2Fnodes%2Ffunctions%2Findex.txt)

Ask ChatGPT
(https://chatgpt.com/?q=Please%20help%20me%20understand%20this%20documentation%3A%20%2Fkida%2Fapi%2Fnodes%2Ffunctions%2Findex.txt)

Ask Gemini
(https://gemini.google.com/app?q=Please%20help%20me%20understand%20this%20documentation%3A%20%2Fkida%2Fapi%2Fnodes%2Ffunctions%2Findex.txt)

Ask Copilot
(https://copilot.microsoft.com/?q=Please%20help%20me%20understand%20this%20documentation%3A%20%2Fkida%2Fapi%2Fnodes%2Ffunctions%2Findex.txt)

Module

#
`nodes.functions`

Function definition and call nodes for Kida AST.

6Classes

## Classes

`DefParam`

2

▼

A single parameter in a {% def %} with optional type annotation.

A single parameter in a {% def %} with optional type annotation.

#### Attributes

Name
Type
Description

`name`

`str`

—

`annotation`

`str | None`

—

`Def`

7

▼

Function definition: {% def name(params) %}...{% end %}

Function definition: {% def name(params) %}...{% end %}

#### Attributes

Name
Type
Description

`name`

`str`

—

`params`

`Sequence[DefParam]`

—

`body`

`Sequence[Node]`

—

`defaults`

`Sequence[Expr]`

—

`vararg`

`str | None`

—

`kwarg`

`str | None`

—

#### Methods

`args`

0

`tuple[str, ...]`

▼

Backward-compat bridge: returns parameter names.

property

`def args(self) -> tuple[str, ...]`

##### Returns

`tuple[str, ...]`

`Region`

8

▼

Parameterized renderable unit: {% region name(params) %}...{% end %}.

Compiles to BOTH a block fun…

Parameterized renderable unit: {% region name(params) %}...{% end %}.

Compiles to BOTH a block function (for render_block) AND a callable
(for {{ name(args) }}). Parameters make it self-contained.

#### Attributes

Name
Type
Description

`name`

`str`

—

`params`

`Sequence[DefParam]`

—

`body`

`Sequence[Node]`

—

`defaults`

`Sequence[Expr]`

—

`vararg`

`str | None`

—

`kwarg`

`str | None`

—

`condition`

`Expr | None`

—

#### Methods

`args`

0

`tuple[str, ...]`

▼

Backward-compat bridge: returns parameter names.

property

`def args(self) -> tuple[str, ...]`

##### Returns

`tuple[str, ...]`

`Slot`

3

▼

Slot placeholder inside {% def %}: {% slot %} or {% slot name %}

With scoped bindings: {% slot nam…

Slot placeholder inside {% def %}: {% slot %} or {% slot name %}

With scoped bindings: {% slot name let:item=expr %}...default...{% end %}
Bindings expose data from the def body to the caller's slot content.
When a body is present, it serves as default content when no caller
overrides this slot.

#### Attributes

Name
Type
Description

`name`

`str`

—

`bindings`

`tuple[tuple[str, Expr], ...]`

—

`body`

`Sequence[Node]`

—

`SlotBlock`

3

▼

Named slot content inside {% call %}: {% slot name %}...{% end %}

With scoped params: {% slot name…

Named slot content inside {% call %}: {% slot name %}...{% end %}

With scoped params: {% slot name let:item, let:index %}...{% end %}
Params declare which scoped bindings the slot body consumes.

#### Attributes

Name
Type
Description

`name`

`str`

—

`body`

`Sequence[Node]`

—

`params`

`tuple[str, ...]`

—

`CallBlock`

4

▼

Call function with slot content: {% call name(args) %}...{% end %}

Call function with slot content: {% call name(args) %}...{% end %}

#### Attributes

Name
Type
Description

`call`

`Expr`

—

`slots`

`dict[str, Sequence[Node]]`

—

`args`

`Sequence[Expr]`

—

#### Methods

`body`

0

`Sequence[Node]`

▼

Backward-compat: default slot content.

property

`def body(self) -> Sequence[Node]`

##### Returns

`Sequence[Node]`
