Render template using Jinja2. Args: template: HTML template string with Jinja2 syntax context: Dictionary of variables to substitute Returns: Rendered HTML string
(template: str, context: Dict[str, Any])
| 18 | |
| 19 | |
| 20 | def render_template(template: str, context: Dict[str, Any]) -> str: |
| 21 | """ |
| 22 | Render template using Jinja2. |
| 23 | |
| 24 | Args: |
| 25 | template: HTML template string with Jinja2 syntax |
| 26 | context: Dictionary of variables to substitute |
| 27 | |
| 28 | Returns: |
| 29 | Rendered HTML string |
| 30 | """ |
| 31 | # Create Jinja2 environment with string template |
| 32 | env = Environment( |
| 33 | loader=StringTemplateLoader(template), |
| 34 | autoescape=select_autoescape(['html', 'xml']), |
| 35 | trim_blocks=True, |
| 36 | lstrip_blocks=True |
| 37 | ) |
| 38 | |
| 39 | # Get template and render |
| 40 | jinja_template = env.get_template('') |
| 41 | return jinja_template.render(**context) |
| 42 | |
| 43 | |
| 44 | def render_navigation(module_tree: Dict[str, Any], current_page: str = "") -> str: |
no test coverage detected