-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathhtml.py
More file actions
21 lines (16 loc) · 738 Bytes
/
Copy pathhtml.py
File metadata and controls
21 lines (16 loc) · 738 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
from jinja2 import Environment, FileSystemLoader, select_autoescape
class Html(object):
def renderHtml(context, html_config):
# Create a Jinja2 environment
env = Environment(
loader=FileSystemLoader(html_config['dir']),
autoescape=select_autoescape(['j2'])
)
# Load the template file
template = env.get_template(html_config['file'])
# Render the template with the provided context
rendered_content = template.render(context)
# Write the rendered content to the output file
with open(html_config['dest'], 'w') as file:
file.write(rendered_content)
print(f"SUCCESS: {html_config['dest']} updated successfully")