EngineHandler
This class manages the configuration and instantiation of multiple template engines based on provided definitions. It provides a dictionary-like interface to access specific engine instances by their alias, ensuring that each backend is lazily loaded and cached for subsequent use. The class also validates that engine aliases are unique and correctly configured within the application settings.
Attributes
| Attribute | Type | Description |
|---|---|---|
| _templates | list = None | Optional list of template engine definitions structured like settings.TEMPLATES used to initialize the handler. |
| _engines | dict = {} | Internal cache mapping engine aliases to their instantiated template engine backend instances. |
| templates | dict | A dictionary mapping unique engine aliases to their normalized configuration parameters, derived from settings.TEMPLATES if not provided during initialization. |
Constructor
Signature
def EngineHandler(
templates: list|null = None
) - > null
Parameters
| Name | Type | Description |
|---|---|---|
| templates | `list | null` = None |
Methods
templates()
@classmethod
def templates() - > dict
Parses and normalizes template engine configurations from settings, ensuring each engine has a unique name and valid backend path.
Returns
| Type | Description |
|---|---|
dict | A dictionary mapping engine aliases to their fully-resolved configuration parameters. |
all()
@classmethod
def all() - > list
Instantiates and returns a list of all template engines defined in the configuration.
Returns
| Type | Description |
|---|---|
list | A list containing initialized engine backend instances for every configured alias. |