kissgyorgy 1 day ago

Check this out: https://compone.kissgyorgy.me/

Much simpler than this library, components are simply functions, rendered to strings.

I made one microbenchmark, it's "only" 2x slower than Jinja2 right now, but I know how to make it faster.

2
anentropic 1 day ago

if you can make it as fast as jinja2 I'm sold ...I haven't done my own benchmarking but so far I haven't seen any of these HTML-in-Python libs able to report comparable performance

I've implemented a bunch of AlpineJS "components" as jinja macros in my current project and ... it works, but it's pretty ugly and it sucks not having type safety or ability for the IDE to understand connections between the template and the Python code

what I really want is something like JSX/TSX for Python... having gone through this process I can see why that approach is desirable. I kind of feel like libs which mimic the syntax but unable to provide the type-safety/IDE support are missing the point. So although I love the look of "Python HTML element objects" approach libs like yours and OP have I think for now it is probably the best way available.

for my current project we are pre-compiling all the jinja templates (via Jinja's own utils) for deployment as AWS Lambda

I did look into JinjaX but it has its own separate jinja env and secondary template cache and didn't look like it would be easy to plug it into the pre-compile step

rubenvanwyk 1 day ago

+1 for TSX for Python, that would be great!

globular-toast 18 hours ago

How many of these are there? I also pointed out htpy elsewhere in the thread.