Externalize sexp to .sexpr files + render() API
All checks were successful
Build and Deploy / build-and-deploy (push) Successful in 1m20s
All checks were successful
Build and Deploy / build-and-deploy (push) Successful in 1m20s
Replace all 676 inline sexp() string calls across 7 services with render(component_name, **kwargs) calls backed by 46 external .sexpr component definition files (587 defcomps total). - Add render() function to shared/sexp/jinja_bridge.py - Add load_service_components() helper and update load_sexp_dir() for *.sexpr - Update parser keyword regex to support HTMX hx-on::event syntax - Convert remaining inline HTML in route files to render() calls - Add shared/sexp/templates/misc.sexp for cross-service utility components Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -138,16 +138,12 @@ def errors(app):
|
||||
messages = getattr(e, "messages", [str(e)])
|
||||
|
||||
if request.headers.get("HX-Request") == "true":
|
||||
# Build a little styled <ul><li>...</li></ul> snippet
|
||||
lis = "".join(
|
||||
f"<li>{escape(m)}</li>"
|
||||
from shared.sexp.jinja_bridge import render as render_comp
|
||||
items = "".join(
|
||||
render_comp("error-list-item", message=str(escape(m)))
|
||||
for m in messages if m
|
||||
)
|
||||
html = (
|
||||
"<ul class='list-disc pl-5 space-y-1 text-sm text-red-600'>"
|
||||
f"{lis}"
|
||||
"</ul>"
|
||||
)
|
||||
html = render_comp("error-list", items_html=items)
|
||||
return await make_response(html, status)
|
||||
|
||||
# Non-HTMX: show a nicer page with error messages
|
||||
@@ -164,8 +160,9 @@ def errors(app):
|
||||
# Extract service name from "Fragment account/auth-menu failed: ..."
|
||||
service = msg.split("/")[0].replace("Fragment ", "") if "/" in msg else "unknown"
|
||||
if request.headers.get("HX-Request") == "true":
|
||||
from shared.sexp.jinja_bridge import render as render_comp
|
||||
return await make_response(
|
||||
f"<p class='text-sm text-red-600'>Service <b>{escape(service)}</b> is unavailable.</p>",
|
||||
render_comp("fragment-error", service=str(escape(service))),
|
||||
503,
|
||||
)
|
||||
# Raw HTML — cannot use render_template here because the context
|
||||
|
||||
Reference in New Issue
Block a user