diff --git a/shared/sx/helpers.py b/shared/sx/helpers.py index ead0b17..4acd87f 100644 --- a/shared/sx/helpers.py +++ b/shared/sx/helpers.py @@ -77,7 +77,7 @@ def _as_sx(val: Any) -> SxExpr | None: if not val: return None if isinstance(val, SxExpr): - return val + return val if val.source else None html = str(val) escaped = html.replace("\\", "\\\\").replace('"', '\\"') return SxExpr(f'(~rich-text :html "{escaped}")') @@ -376,7 +376,10 @@ def _build_component_ast(__name: str, **kwargs: Any) -> list: elif isinstance(val, SxExpr): # SxExpr values need to be parsed into AST from .parser import parse - ast.append(parse(val.source)) + if not val.source: + ast.append(NIL) + else: + ast.append(parse(val.source)) else: ast.append(val) return ast