Add fragment composition infrastructure for micro-frontend UI
New HTTP client (fragments.py) fetches HTML fragments from other apps over the Docker network, with Redis caching and graceful degradation. Jinja global `fragment()` available in all templates. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -107,5 +107,14 @@ def setup_jinja(app: Quart) -> None:
|
||||
from shared.services.widget_registry import widgets as _widget_registry
|
||||
app.jinja_env.globals["widgets"] = _widget_registry
|
||||
|
||||
# fragment composition helper — fetch HTML from another app's fragment API
|
||||
from shared.infrastructure.fragments import fetch_fragment_cached
|
||||
|
||||
async def _fragment(app_name: str, fragment_type: str, ttl: int = 30, **params) -> str:
|
||||
p = params if params else None
|
||||
return await fetch_fragment_cached(app_name, fragment_type, params=p, ttl=ttl)
|
||||
|
||||
app.jinja_env.globals["fragment"] = _fragment
|
||||
|
||||
# register jinja filters
|
||||
register_filters(app)
|
||||
|
||||
Reference in New Issue
Block a user