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.
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
.
env
class-attribute
instance-attribute
¶
env = None
The environment for the template engine. This env is only used for jinja2 templates and its ignored for other template engines.
The env
is a jinja2.Environment
instance.
env_options
class-attribute
instance-attribute
¶
env_options = {}
The options for the template engine. These options are passed to the template engine.
In the case of the jinja2
template engine, these options are passed to the jinja2.Environment
instance and will populate the env_options
parameter.
This is currently only used for the jinja2
template engine and nothing else.