diff --git a/hosts/ocaml/bin/sx_server.ml b/hosts/ocaml/bin/sx_server.ml index eaf8f93b..b4c00115 100644 --- a/hosts/ocaml/bin/sx_server.ml +++ b/hosts/ocaml/bin/sx_server.ml @@ -4869,6 +4869,14 @@ let () = else begin (* Normal persistent server mode *) let env = make_server_env () in + (* render-page: render an (unevaluated) SX page/component expression to HTML + using the server env, so http-listen handlers can serve interactive SX + pages. render-to-html expands components + collects keyword attrs itself; + SX handlers can't reach the server env, so this primitive supplies it. *) + ignore (env_bind env "render-page" (NativeFn ("render-page", fun args -> + match args with + | expr :: _ -> String (sx_render_to_html expr env) + | _ -> raise (Eval_error "render-page: (expr)")))); send "(ready)"; (* Main command loop *) try diff --git a/lib/host/conformance.sh b/lib/host/conformance.sh index 8e4974dd..c5ab4f1b 100755 --- a/lib/host/conformance.sh +++ b/lib/host/conformance.sh @@ -76,6 +76,7 @@ MODULES=( "lib/host/feed.sx" "lib/host/relations.sx" "lib/host/blog.sx" + "lib/host/page.sx" "lib/host/server.sx" "lib/host/ledger.sx" ) @@ -89,6 +90,7 @@ SUITES=( "feed host-fd-tests-run! lib/host/tests/feed.sx" "relations host-rl-tests-run! lib/host/tests/relations.sx" "blog host-bl-tests-run! lib/host/tests/blog.sx" + "page host-pg-tests-run! lib/host/tests/page.sx" "server host-sv-tests-run! lib/host/tests/server.sx" "ledger host-lg-tests-run! lib/host/tests/ledger.sx" ) diff --git a/lib/host/page.sx b/lib/host/page.sx new file mode 100644 index 00000000..6afa5eba --- /dev/null +++ b/lib/host/page.sx @@ -0,0 +1,22 @@ +;; lib/host/page.sx — serve interactive SX component/island pages on the host +;; (Phase 5: the generic interactive-SX-page capability). +;; +;; The bare `render-to-html` path mangles an EVALUATED component tree's keyword +;; attributes ((form :id ..) -> "