vibe.functions¶
Jinja template helper functions for VIBE.
ComponentSetup ¶
Consolidated setup data for component processing (insert/appendix).
render_component_default ¶
render_component_default(template_string: str | object, host_context: NestedValue, track_access: bool = False) -> str | object | tuple[str | object, set[str]]
Render a component_defaults template string using host context.
| Parameters: |
|
|---|
| Returns: |
|
|---|
need ¶
need(variable_value: object) -> str
Mark a variable as required in authoring context.
Used in templates to indicate that a value is needed for a coherent preview without affecting runtime rendering. Returns an empty string so it is safe to call inline during static validation or preview rendering.
defined ¶
defined(variable_path: str) -> bool
Check if a variable has a non-None value in the session's 'answers' NestedValue structure.
Designed to be used as a Jinja function like {% if defined('a.b.c') }}.
| Parameters: |
|
|---|
| Returns: |
|
|---|
show_message ¶
show_message(block_variable: object) -> str
Provide placeholder Jinja function {{ show(block_id) }}.
Execution during template evaluation triggers access tracking of 'block_variable' by the NestedValue context when probing. Return an empty string to avoid rendering anything itself.
insert ¶
insert(ctx: Context, component_id: str, **params: object) -> str | Subdoc
Handle component insertion during Jinja processing.
Workflow: 1. Initialize (handled by _initialize_component_call): - Parse arguments and validate context - Locate and load component - Setup component processing infrastructure 2. Prepare component context from multiple sources 3. Execute phase-specific logic: - PROBING: Run recursive probe, track dependencies, propagate needs - RENDERING: Render component with full context, handle format conversions
Assumes static analysis has validated the insert() call and component,
and populated _host_template with component_instances_ast and
loaded_components_map.
appendix ¶
appendix(ctx: Context, component_id: str, alias: str, parent: AppendixReference | None = None, **params: object) -> AppendixReference
Handle appendix registration during Jinja processing.
Workflow: 1. Initialize (handled by _initialize_component_call): - Parse arguments and validate context - Locate and load component (with dynamic loading fallback) - Setup component processing infrastructure 2. Prepare component context from multiple sources 3. Execute phase-specific logic: - PROBING: Run recursive probe, track dependencies, register with manager - RENDERING: Return AppendixReference for later document generation
Unlike insert(), appendix() creates separate documents and returns AppendixReference objects for hierarchical numbering and delayed rendering.
| Parameters: |
|
|---|
| Returns: |
|
|---|
| Raises: |
|
|---|
komma_eller ¶
komma_eller(*args: object, **kwargs: object) -> str
Swedish typography helper: join items with comma and 'eller' (or).
Provided for legacy template content; implemented as a no-op in Python and handled in authoring-facing filters elsewhere. Safe to call during static validation.
komma_och ¶
komma_och(*args: object, **kwargs: object) -> str
Swedish typography helper: join items with comma and 'och' (and).
Provided for legacy template content; implemented as a no-op in Python and handled in authoring-facing filters elsewhere. Safe to call during static validation.