Add s-expression wire format support and test detail view
- HTMX beforeSwap hook intercepts text/sexp responses and renders them client-side via sexp.js before HTMX swaps the result in - sexp_response() helper for returning text/sexp from route handlers - Test detail page (/test/<nodeid>) with clickable test names - HTMX navigation to detail returns sexp wire format (4x smaller than pre-rendered HTML), full page loads render server-side - ~test-detail component with back link, outcome badge, and error traceback display Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -1261,6 +1261,18 @@
|
||||
Sexp.processScripts(e.detail.target);
|
||||
Sexp.hydrate(e.detail.target);
|
||||
});
|
||||
|
||||
// S-expression wire format: intercept text/sexp responses and render to HTML
|
||||
// before HTMX swaps them in. Server sends Content-Type: text/sexp with
|
||||
// s-expression body; sexp.js renders to HTML string for HTMX to swap.
|
||||
document.addEventListener("htmx:beforeSwap", function (e) {
|
||||
var xhr = e.detail.xhr;
|
||||
var ct = xhr.getResponseHeader("Content-Type") || "";
|
||||
if (ct.indexOf("text/sexp") === -1) return;
|
||||
// Render s-expression response to HTML string
|
||||
var html = Sexp.renderToString(xhr.responseText);
|
||||
e.detail.serverResponse = html;
|
||||
});
|
||||
}
|
||||
|
||||
})(typeof window !== "undefined" ? window : this);
|
||||
|
||||
Reference in New Issue
Block a user