Module

rendering.template_engine.environment

Jinja2 environment creation and configuration for template engine.

Provides environment setup, theme resolution, and template directory discovery.

Related Modules:

  • bengal.rendering.template_engine.core: Uses this for environment creation
  • bengal.utils.theme_registry: Theme package resolution

Functions

resolve_theme_chain
Resolve theme inheritance chain starting from the active theme. Order: child first → parent → ... …
2 list[str]
def resolve_theme_chain(active_theme: str | None, site: Any) -> list[str]

Resolve theme inheritance chain starting from the active theme.

Order: child first → parent → ... (do not duplicate 'default').

Parameters 2

Name Type Default Description
active_theme str | None

Active theme name

site Any

Site instance

Returns

list[str]

List of theme names in inheritance order

read_theme_extends
Read theme.toml for 'extends' from site, installed, or bundled theme path.
2 str | None
def read_theme_extends(theme_name: str, site: Any) -> str | None

Read theme.toml for 'extends' from site, installed, or bundled theme path.

Parameters 2

Name Type Default Description
theme_name str

Theme name to look up

site Any

Site instance

Returns

str | None

Parent theme name if extends is set, None otherwise

create_jinja_environment
Create and configure Jinja2 environment.
3 tuple[Environment, …
def create_jinja_environment(site: Any, template_engine: Any, profile_templates: bool = False) -> tuple[Environment, list[Path]]

Create and configure Jinja2 environment.

Parameters 3

Name Type Default Description
site Any

Site instance

template_engine Any

TemplateEngine instance (for function bindings)

profile_templates bool False

Whether template profiling is enabled

Returns

tuple[Environment, list[Path]]

Tuple of (Jinja2 Environment, list of template directories)