-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #24 from rtuszik/develop
v0.5.0
- Loading branch information
Showing
13 changed files
with
1,319 additions
and
1,425 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,3 @@ | ||
pyyaml==6.0.2 | ||
jinja2==3.1.4 | ||
python-dotenv==1.0.1 | ||
ruamel.yaml==0.18.6 |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,28 @@ | ||
from jinja2 import Template | ||
from jinja2 import Environment, FileSystemLoader | ||
from logger import get_logger | ||
from pathlib import Path | ||
|
||
logging = get_logger() | ||
|
||
def render_template(template_path, data): | ||
""" | ||
Render a template from the given path with provided data. | ||
""" | ||
try: | ||
with open(template_path, "r") as file: | ||
template = Template(file.read()) | ||
# Use the templates directory directly | ||
templates_dir = Path(__file__).parent / "templates" | ||
|
||
env = Environment( | ||
loader=FileSystemLoader(str(templates_dir)) | ||
) | ||
|
||
template = env.get_template(str(template_path)) | ||
return template.render(**data) | ||
|
||
except FileNotFoundError: | ||
logging.error(f"Error: Template file '{template_path}' not found.") | ||
return None | ||
except Exception as e: | ||
logging.error(f"Error reading template file: {e}") | ||
return None | ||
|
||
try: | ||
return template.render(**data) | ||
except Exception as e: | ||
logging.error(f"Error rendering template: {e}") | ||
return None |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
<!DOCTYPE html> | ||
<html lang="en" charset="UTF-8"> | ||
<head> | ||
<meta charset="UTF-8" /> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0" /> | ||
{% block header %}{% endblock %} | ||
<title> | ||
{% block title %}{% endblock %} | ||
</title> | ||
{% block page_styles %}{% endblock %} | ||
</head> | ||
<body class="dark-mode"> | ||
{% block content %}{% endblock %} | ||
{% block javascript %}{% endblock %} | ||
</body> | ||
</html> |
Oops, something went wrong.