File size: 718 Bytes
71a764a
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
"""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 ""