2 ms·
With HTMX you shouldn't have a "template" per action. Most actions work on some "entity", and the "entity"'s page should be returned by the action, as it's very
by brabel 3y ago
With HTMX you shouldn't have a "template" per action. Most actions work on some "entity", and the "entity"'s page should be returned by the action, as it's very common for an action that change one bit of the "entity" to affect more than one part of the "entity" rendering. So you don't need one template per action, you need one template per entity, and different actions may replace the same entity. This is almost exactly what you would do in React, with "entities" being "components". I've designed a HTMX app this way and actually called the "templates" components. Each component is either a function or an actual (Kotlin) class with a render method. I can test the components in isolation, just like you can with JS frameworks, but all code is on the server - despite the app itself feeling just as reactive as any JS framework-based app.