Functions
validate_block_exists
3
bool
▼
Check if a block exists in a template (including inherited blocks).
Uses list_…
validate_block_exists
3
bool
▼
def validate_block_exists(env: Environment, template_name: str, block_name: str) -> bool
Check if a block exists in a template (including inherited blocks).
Uses list_blocks() which reflects the effective block map after inheritance. Useful for frameworks to validate ViewRef/block_name before calling render_block().
Parameters
| Name | Type | Description |
|---|---|---|
env |
Environment |
Kida Environment. |
template_name |
str |
Template identifier (e.g., "page.html"). |
block_name |
str |
Block to check (e.g., "content", "page_root"). |
Returns
bool
validate_template_block
2
bool
▼
Check if a block exists in a Template instance.
Convenience when you already h…
validate_template_block
2
bool
▼
def validate_template_block(template: Template, block_name: str) -> bool
Check if a block exists in a Template instance.
Convenience when you already have a loaded Template. Uses list_blocks() which includes inherited blocks.
Parameters
| Name | Type | Description |
|---|---|---|
template |
Template |
Loaded Kida Template. |
block_name |
str |
Block to check. |
Returns
bool
get_structure
2
TemplateStructureManifes…
▼
Get lightweight structure manifest for a template.
Returns block names, extend…
get_structure
2
TemplateStructureManifes…
▼
def get_structure(env: Environment, template_name: str) -> TemplateStructureManifest | None
Get lightweight structure manifest for a template.
Returns block names, extends parent, block hashes, and dependencies. Cached by Environment for reuse. Returns None if template not found or analysis unavailable (e.g., no preserved AST).
Parameters
| Name | Type | Description |
|---|---|---|
env |
Environment |
Kida Environment. |
template_name |
str |
Template identifier. |
Returns
TemplateStructureManifest | None
block_role_for_framework
3
str | None
▼
Classify block metadata into framework-relevant roles.
Maps BlockMetadata.infe…
block_role_for_framework
3
str | None
▼
def block_role_for_framework(block_metadata: Any, *, content_roles: frozenset[str] = frozenset({'content', 'main', 'page_content'}), root_roles: frozenset[str] = frozenset({'page_root', 'root', 'layout'})) -> str | None
Classify block metadata into framework-relevant roles.
Maps BlockMetadata.inferred_role and block name to Chirp-style roles:
- "fragment": suitable for narrow fragment (content, main)
- "page_root": suitable for boosted page root
- None: unknown or not applicable
Parameters
| Name | Type | Description |
|---|---|---|
block_metadata |
Any |
BlockMetadata from template_metadata().blocks. |
content_roles |
frozenset[str] |
Block names treated as content/fragment. Default:frozenset({'content', 'main', 'page_content'})
|
root_roles |
frozenset[str] |
Block names treated as page root. Default:frozenset({'page_root', 'root', 'layout'})
|
Returns
str | None