Classes
TemplateStructureBlockParsingMixin
8
▼
Mixin for parsing template structure blocks.
Host attributes and cross-mixin dependencies are decl…
TemplateStructureBlockParsingMixin
8
▼
Mixin for parsing template structure blocks.
Host attributes and cross-mixin dependencies are declared via inline TYPE_CHECKING blocks. Inherits block stack management from BlockStackMixin.
Methods
Internal Methods 8 ▼
_parse_block_tag
0
Block
▼
Parse {% block name [if expr] %}...{% end %} or {% endblock %}.
The optional `…
_parse_block_tag
0
Block
▼
def _parse_block_tag(self) -> Block
Parse {% block name [if expr] %}...{% end %} or {% endblock %}.
The optionalif exprguard causes the block to be skipped
during full render when the expression is falsy.
Returns
Block
_parse_globals_tag
0
Globals
▼
Parse {% globals %}...{% end %} — setup block for render_block().
The globals …
_parse_globals_tag
0
Globals
▼
def _parse_globals_tag(self) -> Globals
Parse {% globals %}...{% end %} — setup block for render_block().
The globals block defines macros and variables that are available during both full render() and render_block(). This solves the problem of macros defined in base templates being invisible during fragment rendering.
Only one {% globals %} block is allowed per template.
Returns
Globals
_parse_imports_tag
0
Imports
▼
Parse {% imports %}...{% end %} — intent-revealing imports for fragments.
Same…
_parse_imports_tag
0
Imports
▼
def _parse_imports_tag(self) -> Imports
Parse {% imports %}...{% end %} — intent-revealing imports for fragments.
Same semantics as {% globals %} but signals: these are imports for fragment/block scope. Compiles to _globals_setup.
Returns
Imports
_parse_fragment_tag
0
Block
▼
Parse {% fragment name %}...{% end %} — fragment-only block.
Fragment blocks a…
_parse_fragment_tag
0
Block
▼
def _parse_fragment_tag(self) -> Block
Parse {% fragment name %}...{% end %} — fragment-only block.
Fragment blocks are skipped during full template render() and only rendered when explicitly requested via render_block(). This avoids UndefinedError for blocks whose variables are only provided during fragment rendering (e.g., htmx OOB swaps, SSE partials).
Returns
Block
_parse_extends
0
Extends
▼
Parse {% extends "base.html" %}.
_parse_extends
0
Extends
▼
def _parse_extends(self) -> Extends
Returns
Extends
_parse_include
0
Include
▼
Parse {% include "partial.html" [with context] [ignore missing] %}.
_parse_include
0
Include
▼
def _parse_include(self) -> Include
Returns
Include
_parse_import
0
Import
▼
Parse {% import "template.html" as f [with context] %}.
_parse_import
0
Import
▼
def _parse_import(self) -> Import
Returns
Import
_parse_from_import
0
FromImport
▼
Parse {% from "template.html" import name1, name2 as alias %}.
_parse_from_import
0
FromImport
▼
def _parse_from_import(self) -> FromImport
Returns
FromImport