-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Static template that doesn't parse the response #3082
Comments
As you linked the v1 docs, I suppose you're using htmx v1 and not v2 here ? |
Is the mismatch between ids relevant (unrecoverable vs. unhandled)? |
No - sorry that is a copy paste error from reformatting the real markup to be easier to read for the example. What happens here is the server returns a response with an error status code. HTMX produces a Json Decoding error because the error response isn't formatted with JSON. And then HTMX inserts the server response instead of the static message from the template. |
Perhaps you could add something like: |
Awesome! Thanks! |
I tried this:
It did not solve the issue. Note that it seems to work without |
According to docs, default handling is: responseHandling: [
{code:"204", swap: false}, // 204 - No Content by default does nothing, but is not an error
{code:"[23]..", swap: true}, // 200 & 300 responses are non-errors and are swapped
{code:"[45]..", swap: false, error:true}, // 400 & 500 responses are not swapped and are errors
{code:"...", swap: false} // catch all for any other response code
] So there should be no difference between 4xx and 5xx errors. The
Possibly also need to set You can get value Here is how htmx matches status code: function codeMatches(responseHandlingConfig, status) {
var regExp = new RegExp(responseHandlingConfig.code)
return regExp.test(status.toString(10))
} |
With a current use case, the response from the POST isn't important - the side effect is handled by
path-deps
and that handles the re-render. It is only important to let the user know there if was an error.As such, it would be helpful to be able to provide a static template block that does not parse the response.
For example:
Using the available template engines causes a Parsing error in Javascript when JSON isn't returned by a 500 error and htmx falls back to inserting the response into "#unhandled-error" instead of the static message.
Being able to force the static message to display would be very beneficial.
The text was updated successfully, but these errors were encountered: