|
|
|
|
|
by pphysch
350 days ago
|
|
HTMX can easily get spooky. One pattern to avoid that is to not use separate routes for HTMX endpoints. Instead, use a special GET param or header to tell the server that this request is for a specific HTML fragment. /page1, /page1/click1 (bad) /page1, /page1?htmx=click1 (good) Then have a common server pattern for how you inspect the request to determine which fragment (or whole page) to respond with. With this, navigating HTMX code is much nicer because you only have to identify one entry point instead of hopping through the codebase to identify the N different URLs and view functions that support the page. |
|
The development principle still stands, however, and, like all dev principals, has trade offs associated with it.