← This Week in HTMX

Issue № 13: Shade of the Lime Tree

, Deniz Akşimşek

Blogs Corner

Andrew Meier, Dynamic forms with hyperscript

By ‘dynamic form’ I mean an HTML form where the inputs can change based on how the user populates the form. I tend to need this when there is an array type in the data and the number of elements in the array is specified by the user, or when there is a union type in the data and I want to change the inputs shown based on the case selected by the user. An example is worth a thousand more words.

https://andrewmeier.dev/dynamic-forms-hyperscript

Maarten Balliauw, HTMX for ASP.NET Core Developers – Tutorial

If you’re developing ASP.NET Core applications, and are looking at building a rich client-side experience, you’re in luck. We just published a new tutorial to the JetBrains .NET Guide:

HTMX for ASP.NET Core Developers

In this tutorial, our developer advocate Khalid Abuhakmeh introduces you to HTMX, and how to integrate it into your ASP.NET Core apps.

JetBrains’ support for htmx is still quite surreal. The tutorial is freely available to all:

ASP.NET Core developers predominantly spend their development time on the server, trying their best to steer clear of the scary world of client-side development. But here’s a secret, it doesn’t have to be a daunting prospect to build client-side experiences if you use HTMX. Learn what HTMX is, how to integrate it with your existing knowledge of ASP.NET Core development, and how to take your client-side development to the next level with relative ease. You’ll never look at client-side development the same way ever again.

https://blog.jetbrains.com/dotnet/2022/04/27/htmx-for-asp-net-core-developers-tutorial/

Haskell + htmx + _hyperscript?

Rashad Gover, Hypermedia-Driven Web Apps in Haskell

In this talk I present a new approach to building web apps in Haskell, using htmx. htmx gives you access to AJAX, CSS Transitions, WebSockets and Server Sent Events directly in HTML, using attributes, so you can build modern user interfaces with the simplicity and power of hypertext. With the power of this technology, Haskellers can now build 100% Haskell web apps without depending on GHCJS. I’ll also be briefly showcasing a new microframework based on monadic parsing called Okapi. Okapi was inspired by F#’s Giraffe, and is meant to be a lightweight, simple tool used for rapid prototyping and learning server-side web development.

The talk will be held online on .

Best of luck to Rashad on the talk! 💙💙💙

https://hfpug.org/event/rashad-gover-hypermedia-driven-web-apps-in-haskell/


Our own Rashad and Anthony have been working on some very cool things:

_hyperscript for Sublime Text coming soon

gnat has been contributing to the _hyperscript grammar that powers the VSCode plugin, and has undertook a Sublime Text plugin based on the same grammar.

The plugin is now awaiting approval – a rather involved process.

Thanks to gnat for these contributions! 💙

https://github.com/wbond/package_control_channel/pull/8517

The _hyperscript code organization debate

Seems pretty positive so far, right? But there are some caveats…

I hadn’t even thought of this, since I never try to view local HTML files without a server. That’s why participating in the development of things you use is important! 🐝

The _hyperscript codebase has grown quite quickly, and to simplify it, we need your feedback:

How to test HTML templates

This story is very important and definitely not a front for me to promote microformats.

Use the 204 No Content status code to optimize polling

A user had a table being polled every 2 seconds. The table was being augmented with a JavaScript library, which caused jitter every time the server was polled — regardless of whether the table changed.

You can use the 204 No Content status code to tell browsers they should keep showing the old page, and htmx respects this convention by not swapping.

There is actually a bit of a debate about whether htmx should swap 204 responses. I hold that if you need anything visible to happen upon the response being received, 204 is the wrong status code to use — use 200 OK with an empty body instead.