Download Hugging Face/templating.py from Corin1998/3: direct link, hf CLI and curl.
- Browser
- Download file 392 Bytes
-
https://huggingface.co/spaces/Corin1998/3/resolve/main/Hugging%20Face/templating.py
- Command line
-
hf download 'hf://spaces/Corin1998/3/Hugging Face/templating.py'
-
curl -L -o templating.py https://huggingface.co/spaces/Corin1998/3/resolve/main/Hugging%20Face/templating.py
392 Bytes
| from jinja2 import Environment, FileSystemLoader, select_autoescape | |
| def get_env(templates_dir: str): | |
| env = Environment( | |
| loader=FileSystemLoader(templates_dir), | |
| autoescape=select_autoescape(["html", "xml"]) | |
| ) | |
| return env | |
| def render(env, template_name: str, context: dict) -> str: | |
| template = env.get_template(template_name) | |
| return template.render(**context) |