Externalize sexp component templates and delete redundant HTML fragments
All checks were successful
Build and Deploy / build-and-deploy (push) Successful in 1m13s

Move 24 defcomp definitions from Python string constants in components.py
to 7 grouped .sexp files under shared/sexp/templates/. Add load_sexp_dir()
to jinja_bridge.py for file-based loading. Migrate events and market
link-card fragment handlers from render_template to sexp. Delete 9
superseded Jinja HTML fragment templates.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-02-28 08:55:54 +00:00
parent 9c6170ed31
commit 53c4a0a1e0
20 changed files with 506 additions and 1029 deletions

View File

@@ -176,6 +176,7 @@ def register():
async def _link_card_handler():
from shared.infrastructure.urls import events_url
from shared.sexp.jinja_bridge import sexp as render_sexp
slug = request.args.get("slug", "")
keys_raw = request.args.get("keys", "")
@@ -193,12 +194,10 @@ def register():
g.s, "page", post.id,
)
cal_names = ", ".join(c.name for c in calendars) if calendars else ""
parts.append(await render_template(
"fragments/link_card.html",
title=post.title,
feature_image=post.feature_image,
calendar_names=cal_names,
link=events_url(f"/{post.slug}"),
parts.append(render_sexp(
'(~link-card :title title :image image :subtitle subtitle :link link)',
title=post.title, image=post.feature_image,
subtitle=cal_names, link=events_url(f"/{post.slug}"),
))
return "\n".join(parts)
@@ -213,12 +212,10 @@ def register():
g.s, "page", post.id,
)
cal_names = ", ".join(c.name for c in calendars) if calendars else ""
return await render_template(
"fragments/link_card.html",
title=post.title,
feature_image=post.feature_image,
calendar_names=cal_names,
link=events_url(f"/{post.slug}"),
return render_sexp(
'(~link-card :title title :image image :subtitle subtitle :link link)',
title=post.title, image=post.feature_image,
subtitle=cal_names, link=events_url(f"/{post.slug}"),
)
_handlers["link-card"] = _link_card_handler