Remove last Jinja fragment templates, use sx_components directly
Events fragment routes now call render_fragment_container_cards(), render_fragment_account_tickets(), and render_fragment_account_bookings() from sx_components instead of render_template(). Account sx_components handles both SxExpr (text/sx) and HTML (text/html) fragment responses. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -294,26 +294,49 @@ async def render_newsletters_oob(ctx: dict, newsletter_list: list) -> str:
|
||||
# Public API: Fragment pages
|
||||
# ---------------------------------------------------------------------------
|
||||
|
||||
async def render_fragment_page(ctx: dict, page_fragment_html: str) -> str:
|
||||
"""Full page: fragment-provided content."""
|
||||
async def render_fragment_page(ctx: dict, page_fragment: str) -> str:
|
||||
"""Full page: fragment-provided content.
|
||||
|
||||
*page_fragment* may be sx source (from text/sx fragments wrapped in
|
||||
SxExpr) or HTML (from text/html fragments). Sx source is embedded
|
||||
directly; HTML is wrapped in ``~rich-text``.
|
||||
"""
|
||||
from shared.sx.parser import SxExpr
|
||||
hdr = root_header_sx(ctx)
|
||||
hdr_child = header_child_sx(_auth_header_sx(ctx))
|
||||
header_rows = "(<> " + hdr + " " + hdr_child + ")"
|
||||
|
||||
content = _fragment_content(page_fragment)
|
||||
return full_page_sx(ctx, header_rows=header_rows,
|
||||
content=f'(~rich-text :html "{_sx_escape(page_fragment_html)}")',
|
||||
content=content,
|
||||
menu=_auth_nav_mobile_sx(ctx))
|
||||
|
||||
|
||||
async def render_fragment_oob(ctx: dict, page_fragment_html: str) -> str:
|
||||
async def render_fragment_oob(ctx: dict, page_fragment: str) -> str:
|
||||
"""OOB response for fragment pages."""
|
||||
oobs = "(<> " + _auth_header_sx(ctx, oob=True) + " " + root_header_sx(ctx, oob=True) + ")"
|
||||
|
||||
content = _fragment_content(page_fragment)
|
||||
return oob_page_sx(oobs=oobs,
|
||||
content=f'(~rich-text :html "{_sx_escape(page_fragment_html)}")',
|
||||
content=content,
|
||||
menu=_auth_nav_mobile_sx(ctx))
|
||||
|
||||
|
||||
def _fragment_content(frag: object) -> str:
|
||||
"""Convert a fragment response to sx content string.
|
||||
|
||||
SxExpr (from text/sx responses) is embedded as-is; plain strings
|
||||
(from text/html) are wrapped in ``~rich-text``.
|
||||
"""
|
||||
from shared.sx.parser import SxExpr
|
||||
if isinstance(frag, SxExpr):
|
||||
return frag.source
|
||||
s = str(frag) if frag else ""
|
||||
if not s:
|
||||
return ""
|
||||
return f'(~rich-text :html "{_sx_escape(s)}")'
|
||||
|
||||
|
||||
# ---------------------------------------------------------------------------
|
||||
# Public API: Auth pages (login, device)
|
||||
# ---------------------------------------------------------------------------
|
||||
|
||||
Reference in New Issue
Block a user