Fix sx docs pages leaking raw s-expressions and missing sub-row

Three issues fixed:

- async_eval_slot_to_sx (and async_eval_to_sx) was calling serialize()
  on plain strings returned by page helpers, quoting them as literals
  instead of treating them as sx source. Added str check to wrap
  directly in SxExpr.

- _render_to_sx_with_env passed layout kwargs only as env free
  variables, but _aser_component defaults all declared params to NIL
  regardless of env. Now builds the AST with extra_env entries as
  keyword args so they bind through normal param mechanism.

- _nav_items_sx returned plain str; changed to SxExpr so nav fragments
  serialize unquoted when passed as layout kwargs.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-03-04 23:02:23 +00:00
parent 1077fae815
commit 4298d5be16
3 changed files with 21 additions and 3 deletions

View File

@@ -6,7 +6,7 @@ from shared.sx.helpers import (
)
def _nav_items_sx(items: list[tuple[str, str]], current: str | None = None) -> str:
def _nav_items_sx(items: list[tuple[str, str]], current: str | None = None) -> SxExpr:
"""Build nav link items as sx."""
parts = []
for label, href in items:
@@ -15,7 +15,7 @@ def _nav_items_sx(items: list[tuple[str, str]], current: str | None = None) -> s
is_selected="true" if current == label else None,
select_colours="aria-selected:bg-violet-200 aria-selected:text-violet-900",
))
return "(<> " + " ".join(parts) + ")"
return SxExpr("(<> " + " ".join(parts) + ")")
def _doc_nav_sx(items: list[tuple[str, str]], current: str) -> str: