docs(jinjax): document sharing an existing Catalog with JinjaxRenderer (closes #13)#18
Merged
Merged
Conversation
closes #13) Minimal examples create a fresh `Catalog()`, which has its own empty Jinja environment — component templates then silently lose the host app's custom filters, globals (e.g. url_for), and extensions and render incorrectly. - README: add a "Sharing an existing JinjaX catalog" subsection showing the Jinja2Templates env-sharing pattern and `Component.renderer = JinjaxRenderer(existing_catalog)`, with a warning about fresh catalogs. - JinjaxRenderer.__init__: enrich the docstring (surfaces in the pdoc API reference) to direct users to pass their existing catalog. - Add tests/test_jinjax_renderer.py proving a shared catalog's globals and filters reach rendered components, plus a contrast test showing a fresh catalog lacks them. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_017hdmTV88wAXU8ew1rorMjt
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes #13.
JinjaxRenderer(catalog)already accepts an existingCatalog— the gap was purely documentation. Minimal examples create a freshCatalog()with its own empty Jinja environment, so component templates silently lose the host app's custom filters, globals (e.g.url_for), and extensions.Changes
Jinja2Templatesenv-sharing pattern,Component.renderer = JinjaxRenderer(existing_catalog), and a warning explaining why a fresh catalog drops context.JinjaxRenderer.__init__— enriched docstring (surfaces in the pdoc API reference) directing users to pass their existing catalog.tests/test_jinjax_renderer.py(new) — proves a shared catalog's globals + filters reach rendered components; a contrast test shows a fresh catalog lacks them.Acceptance criteria (from #13)
jinja_env).Jinja2Templatesenv-sharing pattern.Testing
tests/test_jinjax_renderer.py(guarded bypytest.importorskip("jinjax")): 2 passed.prek run --all-filesclean (ruff, ruff-format, ty).🤖 Generated with Claude Code