5 ms·
Oh my example wasn't a working one. I was just picking all the weird syntax I saw. What's gross about it is learning things like: ...hx-vals='{"target_stew
by ctvo 3y ago
Oh my example wasn't a working one. I was just picking all the weird syntax I saw. What's gross about it is learning things like:
...hx-vals='{"target_stewards": "1"}'
...hx-target="closest .shift-mini"
The fuck is this? Is this a string wrapping JSON in an HTML tag? In 2023?! And is the second one some weird DSL that targets an HTML element by CSS class?
Why would I learn this. What does it look like to use in a large code base? I think the main difference between me and the folks who love this is I don't hate Javascript enough yet to explore this life.
- simonw 3y agoIt's a DSL in HTML attributes which covers almost all of what I need to build a dynamic web application. https://htmx.org/reference/#attributes https://htmx.org/reference/#attributes When this is clicked, submit this form to this place, then replace this thing with the returned HTML. It's such a breath of fresh air compared to the massive warren of SPA JavaScript I've had to fight with in the past.
- jddj 3y ago> It's a DSL in HTML attributes which covers almost all of what I need to build a dynamic web application. Not quite though right? There's a very tightly coupled (and fairly useless for anything else) sibling endpoint for each of those calls, which exists on a backend somewhere to return the html that you need to progress. The alternative exists. You can spin up a rest API around a database schema in all of 5 minutes (eg. Pocketbase). Put alpinejs on the front end and you have everything htmx can do with no need for the server to get involved in whether or not a modal is open or closed on some client somewhere.
- recursivedoubts 3y agohttps://htmx.org/essays/two-approaches-to-decoupling/ https://htmx.org/essays/two-approaches-to-decoupling/ https://htmx.org/essays/splitting-your-apis/ https://htmx.org/essays/splitting-your-apis/
- jddj 3y agoUnfortunately, the more of this I read the more I'm convinced. Especially in the context of rapid prototyping but also in larger projects. I love serverside templating. I use go templates, asp net razorpages and old laravel blade across various projects. It's hard for me to see the enthusiasm for htmx as anything but an overcorrection from react, and the project itself feels like it chooses ideology over function (nothing wrong with that, just not great for getting things done). In a year I do think we'll see the typical stream of rewrites.
- recursivedoubts 3y agomaybe https://htmx.org/essays/a-real-world-react-to-htmx-port/ https://htmx.org/essays/a-real-world-react-to-htmx-port/
- hirvi74 3y ago> I use go templates, asp net razorpages and old laravel blade across various projects. HTMX + Razor Pages/Views is so freaking nice. It's seriously increased reusability so much for me. HTMX has also greatly reduced the amount of JS I have to write for the same functionality I was getting with Vanilla JS. Depending on what I need, I find the JS API that HTMX has to be very helpful, albeit I wish a few things were a tad better/more clear in the docs for that area (or I was just too much of an idiot to figure out). None the less, I have no intentions of jumping ship from HTMX anytime soon.
- naasking 3y ago> Put alpinejs on the front end and you have everything htmx can do with no need for the server to get involved in whether or not a modal is open or closed on some client somewhere. Modals are driven by database state, so you can't really get rid of that.
- selfmodruntime 3y agoHow you can call this a breath of fresh air is beyond me. This is insanely ugly to me.
- naasking 3y ago> And is the second one some weird DSL What's weird about standard CSS selectors? Maybe you should actually see some testimonials before judging, like: https://www.youtube.com/watch?v=3GObi93tjZI https://www.youtube.com/watch?v=3GObi93tjZI
- ctvo 3y agoWhat's weird is it's an untyped string embedded in an HTML template that does things. The API signature is string in magic out. How do I unit test this? How do we know when someone fat fingered something?
- simonw 3y ago"How do I unit test this?" Playwright should work great for that.
- kodapoda 3y agoYou use Playwright for unit testing? That sounds like an incredibly slow and painful process vs @testing-library.
- Xeamek 3y agoWym? Literally any html attributes/class_names are 'untyped strings that do things'. How is that any different?
- kodapoda 3y agoGP probably means business logic, not setting background color on a div. Coupling HTML with business logic inline reminds me of the good old DHTML. I am really glad the industry moved on from that mess.
- naasking 3y agoBusiness logic must always be executed server-side anyway, so regardless, the client is asking the server "show me the results of this applying business logic". You can do this by having the business logic return a data structure that the client then renders into UI itself, but now you have a state synchronization problem, ie. you have to keep client data structures in sync with server data structures. Alternately, you can use the classic REST pattern: hypermedia as the engine of application state (HATEOAS), and let the server literally tell you what to render, so client state trivially matches server state. This is the htmx way.