Skip to content

TemplateConfig class

Reference for the TemplateConfig class object and how to use it.

Read more about how to use the TemplateConfig in your application and leverage the system.

How to import

from esmerald import TemplateConfig

esmerald.config.template.TemplateConfig

Bases: BaseModel

An instance of TemplateConfig.

This configuration is a simple set of configurations that when passed enables the template engine.

Note

You might need to install the template engine before using this. You can always run pip install esmerald[templates] to help you out.

Example

from esmerald import Esmerald
from esmerald.config.template import TemplateConfig
from esmerald.template.jinja import JinjaTemplateEngine

template_config = TemplateConfig(
    directory=Path("templates"),
    engine=JinjaTemplateEngine,
)

app = Esmerald(template_config=template_config)

engine class-attribute instance-attribute

engine = JinjaTemplateEngine

The template engine to be used.

directory instance-attribute

directory

The directory for the templates in the format of a path like.

Example: /templates.