Classes
SpecialBlockParsingMixin
10
▼
Mixin for parsing special blocks.
Host attributes and cross-mixin dependencies are declared via in…
SpecialBlockParsingMixin
10
▼
Mixin for parsing special blocks.
Host attributes and cross-mixin dependencies are declared via inline TYPE_CHECKING blocks. Inherits block stack management from BlockStackMixin.
Methods
Internal Methods 10 ▼
_parse_with
0
Node
▼
Parse {% with %} in two forms:
1. Conditional: {% with expr %} or {% with expr…
_parse_with
0
Node
▼
def _parse_with(self) -> Node
Parse {% with %} in two forms:
-
Conditional: {% with expr %} or {% with expr as name %}
- Binds expr to 'it' or 'name'
- Skips body if expr is falsy (nil-resilient)
-
Assignment: {% with name = expr, ... %}
- Creates variable bindings
- Always renders body
Detection: If first token after 'with' is a NAME followed by '=', it's assignment style. Otherwise it's conditional (expression followed by 'as' or '%' }).
Returns
Node
_is_assignment_style_with
0
bool
▼
Detect assignment-style: {% with name = expr %}.
Returns True if current token…
_is_assignment_style_with
0
bool
▼
def _is_assignment_style_with(self) -> bool
Detect assignment-style: {% with name = expr %}.
Returns True if current token is NAME and next token is ASSIGN.
Returns
bool
_parse_assignment_with
1
With
▼
Parse assignment-style: {% with x = expr, y = expr2 %}...{% end %}.
Always ren…
_parse_assignment_with
1
With
▼
def _parse_assignment_with(self, start: Token) -> With
Parse assignment-style: {% with x = expr, y = expr2 %}...{% end %}.
Always renders body with the specified variable bindings.
Parameters
| Name | Type | Description |
|---|---|---|
start |
— |
Returns
With
_parse_conditional_with
1
WithConditional
▼
Parse conditional: {% with expr %} or {% with expr as name %}...{% end %}.
Ren…
_parse_conditional_with
1
WithConditional
▼
def _parse_conditional_with(self, start: Token) -> WithConditional
Parse conditional: {% with expr %} or {% with expr as name %}...{% end %}.
Renders body only if expr is truthy. Binds expr to 'name' or 'it'. Supports multiple expressions and bindings: {% with a, b as x, y %}. Also supports {% else %} or {% empty %} for falsy cases.
Parameters
| Name | Type | Description |
|---|---|---|
start |
— |
Returns
WithConditional
_parse_raw
0
Raw
▼
Parse {% raw %}...{% endraw %.
Raw block that prevents template processing of …
_parse_raw
0
Raw
▼
def _parse_raw(self) -> Raw
Parse {% raw %}...{% endraw %.
Raw block that prevents template processing of its content.
Returns
Raw
_parse_capture
0
Capture
▼
Parse {% capture name %}...{% end %} or {% endcapture %.
Capture rendered cont…
_parse_capture
0
Capture
▼
def _parse_capture(self) -> Capture
Parse {% capture name %}...{% end %} or {% endcapture %.
Capture rendered content into a variable.
Returns
Capture
_parse_cache
0
Cache
▼
Parse {% cache key %}...{% end %} or {% endcache %.
Fragment caching with opti…
_parse_cache
0
Cache
▼
def _parse_cache(self) -> Cache
Parse {% cache key %}...{% end %} or {% endcache %.
Fragment caching with optional TTL.
Returns
Cache
_parse_filter_block
0
FilterBlock
▼
Parse {% filter name %}...{% end %} or {% endfilter %.
Apply a filter to an en…
_parse_filter_block
0
FilterBlock
▼
def _parse_filter_block(self) -> FilterBlock
Parse {% filter name %}...{% end %} or {% endfilter %.
Apply a filter to an entire block of content.
Returns
FilterBlock
_parse_spaceless
0
Spaceless
▼
Parse {% spaceless %}...{% end %} or {% endspaceless %}.
Removes whitespace be…
_parse_spaceless
0
Spaceless
▼
def _parse_spaceless(self) -> Spaceless
Parse {% spaceless %}...{% end %} or {% endspaceless %}.
Removes whitespace between HTML tags. Part of RFC: kida-modern-syntax-features.
Returns
Spaceless
_parse_embed
0
Embed
▼
Parse {% embed 'template.html' %}...{% end %} or {% endembed %}.
Embed is like…
_parse_embed
0
Embed
▼
def _parse_embed(self) -> Embed
Parse {% embed 'template.html' %}...{% end %} or {% endembed %}.
Embed is like include but allows block overrides. Part of RFC: kida-modern-syntax-features.
Returns
Embed