pyfcstm.render.env

Jinja2 environment configuration for template rendering.

This module provides a single convenience function, create_env(), which builds a jinja2.Environment configured for pyfcstm template rendering. It augments a new environment with helper filters and globals via pyfcstm.utils.jinja2.add_settings_for_env(), and then injects state machine constants into the global namespace for template usage.

The module exposes the following public component:

  • create_env() - Create a configured Jinja2 environment with state globals

Example:

>>> from pyfcstm.render.env import create_env
>>> env = create_env()
>>> template = env.from_string("Initial state: {{ INIT_STATE }}")
>>> template.render()
'Initial state: ...'

Note

The INIT_STATE and EXIT_STATE globals are imported from pyfcstm.dsl and made available to Jinja2 templates.

create_env

pyfcstm.render.env.create_env() Environment[source]

Create and configure a Jinja2 environment for template rendering.

This function initializes a jinja2.Environment, applies additional filters and globals via pyfcstm.utils.jinja2.add_settings_for_env(), and registers the INIT_STATE and EXIT_STATE values as Jinja2 globals.

Returns:

A configured Jinja2 environment instance.

Return type:

jinja2.Environment

Example:

>>> env = create_env()
>>> template = env.from_string("Initial state: {{ INIT_STATE }}")
>>> rendered = template.render()