Download tasks/leetcode/environment/reference/clone/leetcode_app/render.py from TIGER-Lab/WebsiteBench: direct link, hf CLI and curl.
- Browser
- Download file 1.14 kB
-
https://huggingface.co/datasets/TIGER-Lab/WebsiteBench/resolve/56a2bcbdb1dfe13106943dfedaa63b5ed5932fb8/tasks/leetcode/environment/reference/clone/leetcode_app/render.py
- Command line
-
hf download hf://datasets/TIGER-Lab/WebsiteBench@56a2bcbdb1dfe13106943dfedaa63b5ed5932fb8/tasks/leetcode/environment/reference/clone/leetcode_app/render.py
-
curl -L -o render.py https://huggingface.co/datasets/TIGER-Lab/WebsiteBench/resolve/56a2bcbdb1dfe13106943dfedaa63b5ed5932fb8/tasks/leetcode/environment/reference/clone/leetcode_app/render.py
1.14 kB
| """Jinja2 environment and shared view context.""" | |
| from __future__ import annotations | |
| from pathlib import Path | |
| from typing import Any | |
| from jinja2 import Environment, FileSystemLoader, select_autoescape | |
| from . import content | |
| TEMPLATE_DIR = Path(__file__).resolve().parents[1] / "templates" | |
| environment = Environment( | |
| loader=FileSystemLoader(str(TEMPLATE_DIR)), | |
| autoescape=select_autoescape(("html", "xml")), | |
| trim_blocks=True, | |
| lstrip_blocks=True, | |
| ) | |
| environment.globals.update( | |
| categories=content.CATEGORIES, | |
| sort_options=content.SORT_OPTIONS, | |
| status_options=content.STATUS_OPTIONS, | |
| difficulty_options=content.DIFFICULTY_OPTIONS, | |
| language_labels=content.LANGUAGE_LABELS, | |
| all_topics=content.ALL_TOPICS, | |
| all_languages=content.ALL_LANGUAGES, | |
| ) | |
| environment.filters["language_label"] = content.language_label | |
| environment.filters["difficulty_label"] = content.difficulty_label | |
| environment.filters["category_label"] = content.category_label | |
| environment.filters["sort_label"] = content.sort_label | |
| def render(name: str, **context: Any) -> str: | |
| return environment.get_template(name).render(**context) | |