Classes
Extension
9
▼
Base class for Kida template extensions.
Subclass this to add custom tags, filters, tests, or glob…
Extension
9
▼
Base class for Kida template extensions.
Subclass this to add custom tags, filters, tests, or globals.
Attributes
| Name | Type | Description |
|---|---|---|
tags |
ClassVar[set[str]]
|
Set of block keyword strings this extension handles. When the parser encounters |
end_keywords |
ClassVar[set[str]]
|
Set of end keywords for tags with bodies. E.g., |
node_types |
ClassVar[set[str]]
|
— |
Methods
get_filters
0
dict[str, Callable[..., …
▼
Return filters provided by this extension.
get_filters
0
dict[str, Callable[..., …
▼
def get_filters(self) -> dict[str, Callable[..., Any]]
Returns
dict[str, Callable[..., Any]]
get_tests
0
dict[str, Callable[..., …
▼
Return tests provided by this extension.
get_tests
0
dict[str, Callable[..., …
▼
def get_tests(self) -> dict[str, Callable[..., Any]]
Returns
dict[str, Callable[..., Any]]
get_globals
0
dict[str, Any]
▼
Return global variables provided by this extension.
get_globals
0
dict[str, Any]
▼
def get_globals(self) -> dict[str, Any]
Returns
dict[str, Any]
parse
2
Node
▼
Parse a tag handled by this extension.
Called when the parser encounters a blo…
parse
2
Node
▼
def parse(self, parser: Any, tag_name: str) -> Node
Parse a tag handled by this extension.
Called when the parser encounters a block keyword inself.tags.
The parser's current token is the tag name token.
Parameters
| Name | Type | Description |
|---|---|---|
parser |
— |
The Parser instance (provides _advance, _expect, _parse_expression, _parse_body, etc.) |
tag_name |
— |
The keyword that triggered this call. |
Returns
Node
An AST Node (typically a custom frozen dataclass).
compile
2
list[ast.stmt]
▼
Compile a node produced by this extension's parse().
Called when the compiler …
compile
2
list[ast.stmt]
▼
def compile(self, compiler: Any, node: Node) -> list[ast.stmt]
Compile a node produced by this extension's parse().
Called when the compiler encounters a node whose type name matches a registration from this extension.
Parameters
| Name | Type | Description |
|---|---|---|
compiler |
— |
The Compiler instance (provides _compile_expr, _compile_node, _emit_output, etc.) |
node |
— |
The AST node to compile. |
Returns
list[ast.stmt]
List of Python AST statements.
Internal Methods 1 ▼
__init__
1
▼
__init__
1
▼
def __init__(self, environment: Any) -> None
Parameters
| Name | Type | Description |
|---|---|---|
environment |
— |