Merge branch 'worktree-macros-essays' into macros
Some checks failed
Build and Deploy / build-and-deploy (push) Has been cancelled

This commit is contained in:
2026-03-04 14:48:48 +00:00
2 changed files with 16 additions and 19 deletions

View File

@@ -427,15 +427,20 @@ async def render_to_sx_with_env(__name: str, extra_env: dict, **kwargs: Any) ->
"""Like ``render_to_sx`` but merges *extra_env* into the evaluation
environment before eval. Used by ``register_sx_layout`` so .sx
defcomps can read ctx values as free variables.
Uses ``async_eval_slot_to_sx`` (not ``async_eval_to_sx``) so the
top-level component body is expanded server-side — free variables
from *extra_env* are resolved during expansion rather than being
serialized as unresolved symbols for the client.
"""
from .jinja_bridge import get_component_env, _get_request_context
from .async_eval import async_eval_to_sx
from .async_eval import async_eval_slot_to_sx
ast = _build_component_ast(__name, **kwargs)
env = dict(get_component_env())
env.update(extra_env)
ctx = _get_request_context()
return await async_eval_to_sx(ast, env, ctx)
return await async_eval_slot_to_sx(ast, env, ctx)
async def render_to_sx(__name: str, **kwargs: Any) -> str: