News for hackers. Stuff that matters.
Re:Htmx is part of the GitHub Accelerator by spion on Wednesday August 16, 2023 @01:39PM (#37150663)
How do you organize a backend for a htmx based frontend? Specifically getting templates that serve as reusable components, but also endpoints (there is some proliferation of endpoints which I remember from my days with ASP.NET MVC partials.
Re:Htmx is part of the GitHub Accelerator by recursivedoubts on Wednesday August 16, 2023 @02:05PM (#37151112)
depends a lot on what your backend gives you

i agree it can spiral out of control if you try to do too much, e.g. a routes file that is just incomprehensible

i often end up reusing the same controller method to handle a few related routes, using pattern matching in the route declaration

i think also picking your battles and not getting too fiddly with screens that don't matter so much also helps a lot here

Re:Htmx is part of the GitHub Accelerator by traverseda on Wednesday August 16, 2023 @02:43PM (#37151721)
So you start by just re-sending the entire page but with content changed. Generally you'd use query parameters, like say you have a page with a table and you need to sort it. Add to your query parameters what order you want them in, re-render the whole page.

Then once you've got it figured out you just return the part of the template that you actually need to. Makes sense when you think of it as a progressive enhancement on a plain html page.