// Multi-page static site: home, about, and a dynamic greeting route. // Demonstrates html() pages, path captures, and a 404 fallthrough. cell Site { face { signal request(method: String, path: String, body: String) -> String signal greet(name: String) -> String promise "static pages plus one dynamic route" } on _page(title: String, body: String) { return concat( concat("", title), concat("", concat(body, ""))) } on greet(name: String) { let safe = escape_html(name) return _page("Hello", "

Hello, {safe}!

") } on request(method: String, path: String, body: String) { let req = map("method", method, "path", path) match req { {method: "GET", path: "/"} -> html(_page("Home", "

Welcome

A site in Soma.

")) {method: "GET", path: "/about"} -> html(_page("About", "

About

Built with cells.

")) {method: "GET", path: "/hello/" + nm} -> html(greet(nm)) _ -> html(404, _page("Not Found", "

404

")) } } } cell test SiteTest { rules { assert contains(greet("Ada"), "Hello, Ada!") assert contains(greet(""), "<x>") assert contains(_page("T", "B"), "T") assert contains(_page("T", "B"), "about") } }