vibe.jinja_env

Jinja2 Environment Setup and Configuration (Flask-Independent).

Configures the base Jinja2 environment. Includes: - Setting up the environment with custom Undefined types for probing. - Defining universally available, context-independent custom filters (e.g., markdown, eller) and potentially simple globals. - Pre-compiling static template snippets if needed elsewhere.

EnumerateExtension

Custom Jinja2 extension for the {% enumerate %} block tag.

It parses the main block and nested {% item %} blocks.

Supports localized tag names and parameters for all supported languages. For example, in Swedish: {% upprakning konjunktion="eller" %}{% punkt om x %}{% slut_punkt %}{% slut_upprakning %}

parse

parse(parser: Parser) -> Node

Parse {% enumerate %} and nested {% item %} tags into an AST CallBlock.

StaticCheckEnvironment

Custom environment for static checking that attempts to attach lineno to ProbeMissingPathError.

handle_exception

handle_exception(source: str | None = None) -> NoReturn

Override default handler to capture lineno for ProbeMissingPathError.

register_jinja_extension

register_jinja_extension(extension: type[Extension]) -> None

Register an extra Jinja extension at runtime.

reset_registered_jinja_extensions

reset_registered_jinja_extensions() -> None

Reset extra Jinja extensions (tests only).

get_registered_jinja_extensions

get_registered_jinja_extensions() -> tuple[type[Extension], ...]

Return the full set of Jinja extensions to enable.

create_rendering_environment

create_rendering_environment() -> Environment

Create a clean Jinja environment for document rendering (without probe undefined handling).

This environment is used during final document generation where we have resolved all variables and don't want probe behavior.

register_locale_filter_aliases

register_locale_filter_aliases(env: Environment, locale: str) -> None

Register locale-specific filter aliases on a Jinja environment.

This allows templates to use native language filter names like: - Swedish: {{ word | genitiv }} instead of {{ word | possessive }} - German: {{ word | bestimmt }} instead of {{ word | definite }}

The canonical (English) filter names are always available.

Parameters:
  • env (Environment) –

    The Jinja environment to modify

  • locale (str) –

    The locale code (e.g., "sv", "de", "fr")