Custom Jinja2 loader for string templates.
| 8 | |
| 9 | |
| 10 | class StringTemplateLoader(BaseLoader): |
| 11 | """Custom Jinja2 loader for string templates.""" |
| 12 | |
| 13 | def __init__(self, template_string: str): |
| 14 | self.template_string = template_string |
| 15 | |
| 16 | def get_source(self, environment, template): |
| 17 | return self.template_string, None, lambda: True |
| 18 | |
| 19 | |
| 20 | def render_template(template: str, context: Dict[str, Any]) -> str: |