Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

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.



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.


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


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.


We've come full circle on naming HTML tools!

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


Glad someone got the reference!


I'm glad it was intentional. :-) I don't feel as old. Still old. But less so.


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


I use gomponents with go, which is very similar. The productivity increase is immense. https://github.com/maragudk/gomponents


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.


Search for "clojure hiccup"


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...).


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.


Elm [1] is based on a similar idea. Build your app from pure functions that return HTML tags.

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


Reminds me of dominate.


see also: twisted nevow + stan, which I believe predate the term 'AJAX'.

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




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: