Fix defhandler to produce sx wire format instead of HTML
execute_handler was using async_render() which renders all the way to HTML. Fragment providers need to return sx source (s-expression strings) that consuming apps parse and render client-side. Added async_eval_to_sx() — a new execution mode that evaluates I/O primitives and control flow but serializes component/tag calls as sx source instead of rendering them to HTML. This mirrors how the old Python handlers used sx_call() to build sx strings. Also fixed: _ASER_FORMS checked after HTML_TAGS, causing "map" (which is both an HTML tag and an sx special form) to be serialized as a tag instead of evaluated. Moved _ASER_FORMS check before HTML_TAGS. Also fixed: empty? primitive now handles non-len()-able types gracefully. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -189,7 +189,10 @@ def prim_is_dict(x: Any) -> bool:
|
||||
def prim_is_empty(coll: Any) -> bool:
|
||||
if coll is None or coll is NIL:
|
||||
return True
|
||||
return len(coll) == 0
|
||||
try:
|
||||
return len(coll) == 0
|
||||
except TypeError:
|
||||
return False
|
||||
|
||||
@register_primitive("contains?")
|
||||
def prim_contains(coll: Any, key: Any) -> bool:
|
||||
|
||||
Reference in New Issue
Block a user