News for hackers. Stuff that matters.
Re:HTMx by chatmasta on Friday May 26, 2023 @07:13AM (#36082621)
How do you do that if your backend is setup to respond to requests with partial content? You now need to make sure your backend can render both the full page and also individual components of it. That's not functionality that's provided by HTMX itself.
Re:HTMx by yawaramin on Friday May 26, 2023 @09:27AM (#36083810)
It's fairly easy. Htmx sends an `HX-Request: true` header with all requests. You can check for the presence of this header and have an if/else in your handler to render a partial or a full page. Or if you want to enable caching you can configure the `Accept` header with a customized content type like `text/html;hx=1`. That way you can set a response header `Vary: Accept` to ensure that caching is correct.