Try htpy. It moves templating into python where it can be linted/typed: https://htpy.dev/
The only thing putting me off currently is https://htpy.dev/faq/#how-does-htpy-performance-compare-to-d...
It would be awesome if Python community can get something with these ergonomics that also has performance of Jinja
I believe one could prerender the static parts of the page and get most of the speed of jinja, but the improvement still won’t be noticeable unless the project is very performance sensitive.
So to us, htpy performance has never been an issue which is why we have not been optimizing it further. If anyone is interested in re-implementing parts of htpy in cython/rust/something or improve the performance in other ways, that should be quite doable. The core htpy element/attribute implementation is a few hundred lines of code. It is heavily tested with 1000+ lines of tests. It could be a quite fun project, contributions are welcome!
However to me it seemed like it would mostly improve the ergonomics of using components, whereas the ugliest template code I had was in the component definitions themselves and I think it wouldn't help much there.
Also, for my specific case we were deploying to AWS Lambda and I wanted to pre-compile all the Jinja templates. But JinjaX instantiates its own jinja env so our pre-compilation step (from top-level Django jinja env) couldn't reach the JinjaX defs. Probably there is a way to hack that into working.
Using django-htmx and django-vite libs (the latter forked to add Jinja support)
Been pretty happy with it
The main wart I find is the lack of type-safe templating in Python, feels primitive and clunky compared to what you have with TSX in a React project
Been using Jinja macros as 'components' which... works. The syntax is kinda ugly to read though, and haven't found any really great linter.