sparse-intern-71089
12/07/2021, 9:15 PMprehistoric-activity-61023
12/07/2021, 9:21 PMpulumi.Output
works as expected?polite-mechanic-60124
12/07/2021, 9:21 PMpolite-mechanic-60124
12/07/2021, 9:23 PMprehistoric-activity-61023
12/07/2021, 9:24 PMrender_template_file
defined by you?prehistoric-activity-61023
12/07/2021, 9:25 PMpolite-mechanic-60124
12/07/2021, 9:38 PMpolite-mechanic-60124
12/07/2021, 9:39 PMfrom jinja2 import Environment, PackageLoader, StrictUndefined, select_autoescape
def templating_env() -> Environment:
"""Returns a Jinja templating environment that pulls templates from the `infra.templates` package.
If any expected variables are missing from a template rendering,
an error will be thrown.
"""
return Environment(
loader=PackageLoader("infra"),
autoescape=select_autoescape(),
undefined=StrictUndefined,
)
def render_template_file(
env: Environment, template_name: str, kwargs: Mapping[str, Any]
) -> str:
"""
Render the given Jinja template with the given arguments.
"""
template = env.get_template(template_name)
return template.render(**kwargs)