News for hackers. Stuff that matters.
Re:Ludic: New framework for Python with seamless Htmx support by j4mie on Thursday March 21, 2024 @07:49AM (#39777370)
I wrote a library a little while ago which is intended to be the simplest possible expression of this idea:

https://github.com/j4mie/hotmetal/

The core implementation is only 85 lines of Python, and has no imports at all, so works nicely on minimal/alternative Pythons like Micropython.

I'm using it on a medium-sized side project and it's shockingly productive compared to string templates. I don't think anyone is using it except me, though.

Re:Ludic: New framework for Python with seamless Htmx support by eddieroger on Thursday March 21, 2024 @08:20AM (#39777595)
We've come full circle on naming HTML tools!

https://en.wikipedia.org/wiki/HoTMetaL

Re:Ludic: New framework for Python with seamless Htmx support by j4mie on Thursday March 21, 2024 @10:28AM (#39778894)
Glad someone got the reference!
Re:Ludic: New framework for Python with seamless Htmx support by eddieroger on Monday March 25, 2024 @09:39AM (#39816159)
I'm glad it was intentional. :-) I don't feel as old. Still old. But less so.
Re:Ludic: New framework for Python with seamless Htmx support by slifin on Thursday March 21, 2024 @08:32AM (#39777714)
Search for "clojure hiccup"
Re:Ludic: New framework for Python with seamless Htmx support by egeozcan on Thursday March 21, 2024 @08:39AM (#39777799)
I use gomponents with go, which is very similar. The productivity increase is immense. https://github.com/maragudk/gomponents
Re:Ludic: New framework for Python with seamless Htmx support by tzimo on Thursday March 21, 2024 @08:45AM (#39777845)
This looks really neat. One suggestion is that in your readme, show the webpage output with your examples. It’s hard to image exactly what the page will look like just looking at the hotmetal python code
Re:Ludic: New framework for Python with seamless Htmx support by fermigier on Thursday March 21, 2024 @08:52AM (#39777909)
Cool idea. I had a similar one a few weeks ago, with this additional idea of turning this into a "real" templating language (e.g. by adding a special construct for conditionals, looping, variables, macro expansion...).
Re:Ludic: New framework for Python with seamless Htmx support by samdudley on Thursday March 21, 2024 @08:59AM (#39777957)
Your project looks great and I like the fact you can use it with MicroPython.

I've also been working on a library with a similar idea:

https://github.com/SamDudley/neat-html

It's still a work in progress so an example might be better to look at:

https://github.com/SamDudley/neat-html/blob/main/examples/fo...

I was inspired by some JavaScript libraries that I've used in the past:

- https://github.com/jorgebucaran/hyperapp

- https://github.com/hyperhype/hyperscript

There is also a working integration with Django that enables the use of neat-html as a template backend, however it isn't up on GitHub yet.

I find the space of HTML generation libraries which can leverage the power of Python, really interesting.

Re:Ludic: New framework for Python with seamless Htmx support by borntyping on Thursday March 21, 2024 @09:12AM (#39778107)
I've been looking for something exactly like this for a while β€” a small Python library for generating HTML that isn't prescriptive about framework and doesn't introduce any particually weird syntax. Jinja2 macros are... not great when you want to turn your HTML into lots of smaller functions.
Re:Ludic: New framework for Python with seamless Htmx support by baq on Thursday March 21, 2024 @09:41AM (#39778408)
see also: twisted nevow + stan, which I believe predate the term 'AJAX'.

https://github.com/twisted/nevow/blob/master/examples/simple...

Re:Ludic: New framework for Python with seamless Htmx support by elbear on Thursday March 21, 2024 @10:35AM (#39778975)
This looks like a similar model to how Elm handles HTML. Except Elm provides functions for each tag, so it also does type checking to ensure that the passed arguments correspond to the actual attributes of the tag.
Re:Ludic: New framework for Python with seamless Htmx support by mixmastamyk on Thursday March 21, 2024 @11:03AM (#39779385)
Reminds me of dominate.
Re:Ludic: New framework for Python with seamless Htmx support by polyrand on Thursday March 21, 2024 @11:16AM (#39779586)
This is wonderful, I love it. I recently wrote a blog post about generating HTML in Python using LXML (https://ricardoanderegg.com/posts/python-build-html-componen...) and I didn't know about your library. I'll update it to add a mention to it.

Apart from the simplicity, I like the fact you can "install" it by copy-pasting the code at the top of your script, or running:

  curl -L https://raw.githubusercontent.com/j4mie/hotmetal/main/hotmetal/__init__.py >> myscript.py
which is nice when you want a self-contained file.

I think I'll be using this in the future.

Re:Ludic: New framework for Python with seamless Htmx support by asa400 on Thursday March 21, 2024 @12:24PM (#39780697)
Nice work! There are a few expressions of this idea. There's a reason people keep coming back to it: it's actually really nice to write markup this way.

https://github.com/weavejester/hiccup https://github.com/JuneKelly/sneeze

Re:Ludic: New framework for Python with seamless Htmx support by giovannibonetti on Thursday March 21, 2024 @04:50PM (#39784241)
Elm [1] is based on a similar idea. Build your app from pure functions that return HTML tags.

[1] https://elm-lang.org/