wimdeblauwe / htmx-spring-boot

Spring Boot and Thymeleaf helpers for working with htmx
Apache License 2.0
521 stars 49 forks source link

Add support for processing HtmxResponse in the Model and as an Argument #128

Closed checketts closed 2 months ago

checketts commented 3 months ago

Addresses #127

This enables the following usecase:

@GetMapping("/admin")
fun getAdmin(htmxResponse: HtmxResponse.Builder): JteModel {
    htmxResponse.trigger("aTrigger")
    return templates.adminIndex("Hello")
}

The JteModel is a typed template. But the HtmxResponse can be used as an argument to inform any triggers, redirect, etc. that need to happen.

This change also supports adding HtmxReponse to the model and being processed, if that approach is needed.

wimdeblauwe commented 2 months ago

Can you add some documentation to the README on how to use this?

checketts commented 2 months ago

I've added the readme examples.