Skip to content

Static template that doesn't parse the response #3082

Open
@thenewguy

Description

@thenewguy

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:

<div id="hidden" style="display:none"></div>
<div id="unrecoverable-error"></div>
<template id="unrecoverable-error-template">Some static message explaining that an unknown error was encountered.</template>
<form 
	hx-patch="/endpoint"
	hx-target="#hidden"
	hx-target-error="#unhandled-error"
	handlebars-template="unhandled-error-template"
	hx-on-htmx-before-request="$('#unhandled-error').empty()"
>
	<input type="hidden" name="some-trigger-key" value="1">
	<button type="submit">Submit</button>
</form>

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions