Module

nodes.structure

Template structure nodes for Kida AST.

Classes

TemplateContext 1
Type declaration: {% template page: Page, site: Site %}

Type declaration: {% template page: Page, site: Site %}

Attributes

Name Type Description
declarations Sequence[tuple[str, str]]
Extends 1
Template inheritance: {% extends "base.html" %}

Template inheritance: {% extends "base.html" %}

Attributes

Name Type Description
template Expr
Block 6
Named block for inheritance: {% block name %}...{% end %}

Named block for inheritance: {% block name %}...{% end %}

Attributes

Name Type Description
name str
body Sequence[Node]
scoped bool
required bool
fragment bool
condition Expr | None
Globals 1
Setup block for macros/variables available during render_block().

Setup block for macros/variables available during render_block().

Attributes

Name Type Description
body Sequence[Node]
Imports 1
Imports block — {% imports %}...{% end %}. Same semantics as {% globals %} but signals intent: the…

Imports block — {% imports %}...{% end %}.

Same semantics as {% globals %} but signals intent: these imports are for fragment/block scope. Compiles to _globals_setup.

Attributes

Name Type Description
body Sequence[Node]
Include 3
Include another template: {% include "partial.html" %}

Include another template: {% include "partial.html" %}

Attributes

Name Type Description
template Expr
with_context bool
ignore_missing bool
Import 3
Import functions from template: {% import "funcs.html" as f %}

Import functions from template: {% import "funcs.html" as f %}

Attributes

Name Type Description
template Expr
target str
with_context bool
FromImport 3
Import specific functions: {% from "funcs.html" import button, card %}

Import specific functions: {% from "funcs.html" import button, card %}

Attributes

Name Type Description
template Expr
names Sequence[tuple[str, str | None]]
with_context bool
Template 3
Root node representing a complete template.

Root node representing a complete template.

Attributes

Name Type Description
body Sequence[Node]
extends Extends | None
context_type TemplateContext | None
Cache 4
Fragment caching: {% cache key %}...{% end %}

Fragment caching: {% cache key %}...{% end %}

Attributes

Name Type Description
key Expr
body Sequence[Node]
ttl Expr | None
depends Sequence[Expr]
With 2
Jinja2-style context manager: {% with x = expr %}...{% end %}

Jinja2-style context manager: {% with x = expr %}...{% end %}

Attributes

Name Type Description
targets Sequence[tuple[str, Expr]]
body Sequence[Node]
WithConditional 4
Conditional with block: {% with expr as name %}...{% end %}

Conditional with block: {% with expr as name %}...{% end %}

Attributes

Name Type Description
expr Expr
target Expr
body Sequence[Node]
empty Sequence[Node]
Embed 3
Embed template with block overrides: {% embed 'card.html' %}...{% end %}

Embed template with block overrides: {% embed 'card.html' %}...{% end %}

Attributes

Name Type Description
template Expr
blocks dict[str, Block]
with_context bool