Phase 5: Page layouts as s-expressions — components, fragments, error pages
All checks were successful
Build and Deploy / build-and-deploy (push) Successful in 1m14s
All checks were successful
Build and Deploy / build-and-deploy (push) Successful in 1m14s
Add 9 new shared s-expression components (cart-mini, auth-menu, account-nav-item, calendar-entry-nav, calendar-link-nav, market-link-nav, post-card, base-shell, error-page) and wire them into all fragment route handlers. 404/403 error pages now render entirely via s-expressions as a full-page proof-of-concept, with Jinja fallback on failure. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
32
shared/sexp/page.py
Normal file
32
shared/sexp/page.py
Normal file
@@ -0,0 +1,32 @@
|
||||
"""
|
||||
Full-page s-expression rendering.
|
||||
|
||||
Provides ``render_page()`` for rendering a complete HTML page from an
|
||||
s-expression, bypassing Jinja entirely. Used by error handlers and
|
||||
(eventually) by route handlers for fully-migrated pages.
|
||||
|
||||
Usage::
|
||||
|
||||
from shared.sexp.page import render_page
|
||||
|
||||
html = render_page(
|
||||
'(~error-page :title "Not Found" :message "NOT FOUND" :image img :asset-url aurl)',
|
||||
image="/static/errors/404.gif",
|
||||
asset_url="/static",
|
||||
)
|
||||
"""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
from typing import Any
|
||||
|
||||
from .jinja_bridge import sexp
|
||||
|
||||
|
||||
def render_page(source: str, **kwargs: Any) -> str:
|
||||
"""Render a full HTML page from an s-expression string.
|
||||
|
||||
This is a thin wrapper around ``sexp()`` — it exists to make the
|
||||
intent explicit in call sites (rendering a whole page, not a fragment).
|
||||
"""
|
||||
return sexp(source, **kwargs)
|
||||
Reference in New Issue
Block a user