-
Notifications
You must be signed in to change notification settings - Fork 10
Refactor HTML generation to use Jinja2 templates #107
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Refactor HTML generation to use Jinja2 templates #107
Conversation
- Replaced manual HTML string concatenation in `fitsmap/cartographer.py` with Jinja2 templating. - Added `jinja2` to `pyproject.toml` dependencies. - Created `fitsmap/templates/index.html` template. - Updated `MANIFEST.in` to include the templates directory. - Updated `fitsmap/tests/test_cartographer.py` to support the changes and ensure robust testing. - Ensured generated HTML matches existing test expectations byte-for-byte to maintain compatibility with existing integration tests.
|
👋 Jules, reporting for duty! I'm here to lend a hand with this pull request. When you start a review, I'll add a 👀 emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down. I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job! For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with New to Jules? Learn more at jules.google/docs. For security, I will only act on instructions from the user who triggered this task. |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #107 +/- ##
=======================================
Coverage 95.33% 95.33%
=======================================
Files 6 6
Lines 814 814
=======================================
Hits 776 776
Misses 38 38 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR refactors HTML generation in fitsmap/cartographer.py from manual string concatenation to Jinja2 templating, improving code maintainability and readability.
Key changes:
- Introduced Jinja2 dependency (>=3.1.5) for template-based HTML generation
- Created
fitsmap/templates/index.htmltemplate file to replace thebuild_htmlfunction - Updated tests to remove obsolete
build_htmlunit test and improve robustness withexist_okflags
Reviewed changes
Copilot reviewed 5 out of 6 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
uv.lock |
Added Jinja2 as a dependency in the lock file |
pyproject.toml |
Added jinja2>=3.1.5 to project dependencies |
fitsmap/tests/test_cartographer.py |
Removed test_build_html unit test (function no longer exists), improved test robustness with exist_ok=True for directory creation, and changed file comparison method from filecmp.cmp to direct string comparison for better debugging |
fitsmap/templates/index.html |
New Jinja2 template file containing the HTML structure previously generated by build_html, using template variables for title, extra_js, extra_css, and version |
fitsmap/cartographer.py |
Replaced build_html function with Jinja2 Environment and template rendering; added import for Jinja2 components |
MANIFEST.in |
Added inclusion directive for the new templates directory to ensure templates are included in package distributions |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| env = Environment( | ||
| loader=PackageLoader("fitsmap"), | ||
| autoescape=select_autoescape(), | ||
| ) | ||
|
|
||
| template = env.get_template("index.html") |
Copilot
AI
Jan 6, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The Jinja2 Environment is being created on every call to the chart function. For better performance, consider creating the Environment once at module level since the configuration never changes. This would avoid the overhead of repeatedly initializing the template loader and configuration.
* Refactor index.js generation to use Jinja2 templating Replaces the manual string building logic in `fitsmap/cartographer.py` with a Jinja2 template `fitsmap/templates/index.js.j2`. This improves maintainability and readability of the Javascript generation code. Removed legacy string-building functions from `fitsmap/cartographer.py`. Verified with existing tests. * Refactor index.js generation to use Jinja2 templating Replaces the manual string building logic in `fitsmap/cartographer.py` with a Jinja2 template `fitsmap/templates/index.js.j2`. This improves maintainability and readability of the Javascript generation code. Removed legacy string-building functions from `fitsmap/cartographer.py`. Verified with existing tests. * Refactor index.js generation to use Jinja2 templating Replaces the manual string building logic in `fitsmap/cartographer.py` with a Jinja2 template `fitsmap/templates/index.js.j2`. This improves maintainability and readability of the Javascript generation code. Removed legacy string-building functions from `fitsmap/cartographer.py`. Verified with existing tests. * fixed issue with template causing a test to fail. --------- Co-authored-by: google-labs-jules[bot] <161369871+google-labs-jules[bot]@users.noreply.github.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
Copilot reviewed 6 out of 7 changed files in this pull request and generated 3 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
…ader Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
- Replaced manual HTML string concatenation in `fitsmap/cartographer.py` with Jinja2 templating. - Added `jinja2` to `pyproject.toml` dependencies. - Created `fitsmap/templates/index.html` template. - Updated `MANIFEST.in` to include the templates directory. - Updated `fitsmap/tests/test_cartographer.py` to support the changes and ensure robust testing. - Ensured generated HTML matches existing test expectations byte-for-byte to maintain compatibility with existing integration tests.
|
Was merged using #108 |
This PR refactors the
index.htmlgeneration infitsmap/cartographer.pyto use Jinja2 templating instead of manual string concatenation. This improves code readability and maintainability.Key changes:
jinja2as a dependency.fitsmap/templatesdirectory containingindex.html.fitsmap/cartographer.pyto usejinja2.Environmentandrenderthe template.build_htmlfunction fromfitsmap/cartographer.py.fitsmap/tests/test_cartographer.pyto reflect the changes and removed the obsolete unit test forbuild_html.MANIFEST.into include the new templates.All existing tests pass, ensuring that the generated HTML remains consistent with previous output.
PR created automatically by Jules for task 17170076656376039645 started by @ryanhausen