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.
https://github.com/twisted/nevow/blob/master/examples/simple...
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.
https://github.com/weavejester/hiccup https://github.com/JuneKelly/sneeze
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.