Spaces:
Sleeping
Sleeping
| """Template rendering functionality""" | |
| import os | |
| class TemplateRenderer: | |
| """Handles loading and rendering of HTML templates""" | |
| def load_template(self, template_path, **kwargs): | |
| """Load HTML template from file and format with provided variables""" | |
| try: | |
| with open(f"templates/components/{template_path}", "r", encoding="utf-8") as f: | |
| template_content = f.read() | |
| return template_content.format(**kwargs) | |
| except FileNotFoundError: | |
| print(f"Warning: Template file {template_path} not found") | |
| return "" | |
| except Exception as e: | |
| print(f"Error loading template {template_path}: {e}") | |
| return "" |