Skip to main content

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

AttributeTypeDescription
_templateslist = NoneOptional list of template engine definitions structured like settings.TEMPLATES used to initialize the handler.
_enginesdict = {}Internal cache mapping engine aliases to their instantiated template engine backend instances.
templatesdictA 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

NameTypeDescription
templates`listnull` = 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

TypeDescription
dictA 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

TypeDescription
listA list containing initialized engine backend instances for every configured alias.