nginx-configurator/nginx_configurator/templating.py
2023-11-04 23:08:15 +01:00

15 lines
416 B
Python

import pkgutil
from jinja2 import Environment, FunctionLoader, select_autoescape
def load_template(name):
"""
Loads file from the templates folder and returns file contents as a string.
See jinja2.FunctionLoader docs.
"""
return pkgutil.get_data(f"{__package__}.templates", name).decode("utf-8")
jinja = Environment(
loader=FunctionLoader(load_template), autoescape=select_autoescape()
)