Module

compiler.statements.caching

Caching and filter-block statement compilation for Kida compiler.

Provides mixin for compiling cache blocks and filter blocks -- both follow the "capture output, transform, emit" pattern.

Extracted from special_blocks.py for module focus (RFC: compiler decomposition). Uses inline TYPE_CHECKING declarations for host attributes. See: plan/rfc-mixin-protocol-typing.md

Classes

CachingMixin 2
Mixin for compiling cache and filter-block statements. Host attributes and cross-mixin dependencie…

Mixin for compiling cache and filter-block statements.

Host attributes and cross-mixin dependencies are declared via inline TYPE_CHECKING blocks.

Methods

Internal Methods 2
_compile_cache 1 list[ast.stmt]
Compile {% cache key %}...{% endcache %. Fragment caching. In streaming mode: …
def _compile_cache(self, node: Cache) -> list[ast.stmt]

Compile {% cache key %}...{% endcache %.

Fragment caching. In streaming mode: collect into buffer, cache, then yield. Body always uses StringBuilder mode for caching.

Parameters
Name Type Description
node
Returns
list[ast.stmt]
_compile_filter_block 1 list[ast.stmt]
Compile {% filter name %}...{% endfilter %. Apply a filter to an entire block …
def _compile_filter_block(self, node: FilterBlock) -> list[ast.stmt]

Compile {% filter name %}...{% endfilter %.

Apply a filter to an entire block of content. In streaming mode: collect into buffer, apply filter, yield result.

Parameters
Name Type Description
node
Returns
list[ast.stmt]