vibe.jinja_context

VibeContext - Custom Jinja2 context for VIBE template rendering.

This module provides a custom Jinja context that cleanly separates: - Template data (NestedValue) - accessible via normal variable access - Internal context (host_template, current_state, etc.) - stored as instance attrs

This eliminates the need for INTERNAL_KEYS filtering and cleanup passes.

Usage in templates remains unchanged

{{ variable_name }} -> Accesses template data {% if _is_probing %}... -> Accesses internal context

Usage in Python (Jinja functions): ctx["_host_template"] -> Works via getitem override ctx.get("_is_probing", False) -> Works via get override

VibeContext

Custom Jinja context that stores internal keys as instance attributes.

Internal keys (prefixed with _) are stored separately from template data, so they don't pollute iteration and don't need cleanup.

Attributes:
  • _host_template

    The TemplateData being rendered

  • _current_state

    The current NestedValue state

  • _root_state

    Root state for appendix access

  • _is_probing

    Whether we're in probe phase

  • _is_web_preview

    Whether we're in web preview mode

  • _alias

    Component alias (when rendering components)

  • _docxtpl

    DocxTemplate instance (for DOCX rendering)

  • _vfs

    VFS instance (for file access)

  • _probe_runtime

    Probe runtime helpers

  • _subdoc_registry

    Subdoc registry for DOCX

  • meta

    MetadataNamespace instance

resolve_or_missing

resolve_or_missing(key: str) -> object

Resolve a variable, checking internal attrs first.

get

get(key: str, default: object | None = None) -> object | None

Get item with default, checking internal attrs first.

derived

derived(locals: dict[str, Any] | None = None) -> VibeContext

Create a derived context, preserving internal attrs.

VibeProbeContext

Extended context for probe phase with placeholder resolution.

Inherits all VibeContext functionality and adds: - Placeholder resolution for undefined variables

resolve_or_missing

resolve_or_missing(key: str) -> object

Resolve a variable, using placeholder if not found.

derived

derived(locals: dict[str, Any] | None = None) -> VibeProbeContext

Create a derived context, preserving placeholder resolver.