html_generators - an alternative to templating

I’ve been rather frustrated with the django template system for quite a while. In javascript, I’m a big fan of “hyperscript” libraries that take a functional approach to DOM creation. I’ve wanted something similar in python for quite a while, so I finally ended up writing html_generators.

The library can be used to generate all of the html for your site, but it also inter-operates with the django template system very nicely.

My latest project at work used this library for my html generation (no templates at all), and I’ve been very pleased with it. I may not ever go back to templating.

I’d love to hear your thoughts on the library, or if you’ve ever seen any similar approaches.

1 Like

I am looking for a new way to create HTML with Python, too.

I love f-strings and I love safestring of django.

I found a simple way to combine both, but the IDEs and other tools now think the
variables are unused.

See: python - Implement f-string like magic to pimp Django's format_html() - Stack Overflow