Switched HX-Target header to HX-Request

Using a target like `hx-target="next div"` will not generate an HX-Target header if the target element does not have an ID. Judging by the comments it used to be HX-Request.
This commit is contained in:
Ben Jordan 2025-02-17 19:29:42 -05:00 committed by GitHub
parent da2978ed04
commit 0a4690e001
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -8,10 +8,10 @@ const HtmxMiddleware = @This();
/// request doesn't come via htmx and, when the request does come from htmx, only return the
/// content rendered directly by the view function.
pub fn afterRequest(request: *jetzig.http.Request) !void {
if (request.headers.get("HX-Target")) |target| {
if (request.headers.get("HX-Request")) |_| {
try request.server.logger.DEBUG(
"[middleware-htmx] htmx request detected, disabling layout. (#{s})",
.{target},
"[middleware-htmx] HX-Request header, disabling layout.",
.{},
);
request.setLayout(null);
}