Skip to content

docs(jinjax): document sharing an existing Catalog with JinjaxRenderer (closes #13)#18

Merged
fsecada01 merged 2 commits into
masterfrom
docs/13-share-jinjax-catalog
Jun 24, 2026
Merged

docs(jinjax): document sharing an existing Catalog with JinjaxRenderer (closes #13)#18
fsecada01 merged 2 commits into
masterfrom
docs/13-share-jinjax-catalog

Conversation

@fsecada01

Copy link
Copy Markdown
Owner

Summary

Fixes #13. JinjaxRenderer(catalog) already accepts an existing Catalog — the gap was purely documentation. Minimal examples create a fresh Catalog() 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

  • README — new "Sharing an existing JinjaX catalog" subsection under the FastAPI example: the Jinja2Templates env-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)

  • Document passing your existing catalog directly.
  • Explain why a new catalog loses context (separate jinja_env).
  • Show the Jinja2Templates env-sharing pattern.

Testing

  • tests/test_jinjax_renderer.py (guarded by pytest.importorskip("jinjax")): 2 passed.
  • Full suite: 410 passed.
  • prek run --all-files clean (ruff, ruff-format, ty).

🤖 Generated with Claude Code

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
@fsecada01 fsecada01 added the documentation Improvements or additions to documentation label Jun 24, 2026
@fsecada01 fsecada01 self-assigned this Jun 24, 2026
@fsecada01 fsecada01 merged commit cd48f91 into master Jun 24, 2026
7 checks passed
@fsecada01 fsecada01 mentioned this pull request Jun 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Docs: How to share an existing JinjaX catalog with JinjaxRenderer

1 participant