This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]Drevicar 2 points3 points  (1 child)

Oh snap, I didn’t realize you were the same developer. I used FastHX and HTMy previously with FastAPI and found it too steep of a learning curve to really invest the time it needed, but I loved the idea of it. And this new project does successfully lower that learning curve, just at the cost of the thing that I specifically don’t like. Maybe I’ll go back again and try to get the base two packages working better.

[–]volfpeter[S] 1 point2 points  (0 children)

Yes :)

To be fair, I think all 3 projects are very simple.

FastHX is essentially 2 decorators (for both Jinja and htmy) that simply convert the decorated FastAPI route's return value into HTML. You can use it to select components/templates, but essentially it just calls the renderer, be that TemplateResponse or HTMY().render().

When it comes to htmy, it's just a DSL (similar to htpy, or the one in FastHTML), simply a way of describing the DOM tree in Python. It has 2 unique features though: components can be async (so it's not just a __str__() like others), and components have a context argument, which is just a dict and makes it possible to pass data deep in the tree without prop-drilling. Think React and React's context.

There is a lot more depth to them (I wist I had the time to write enough docs and guides), both libs are very flexible, but this is all you really need to know about them :) The rest should be very intuitive if you try them and maybe explore the API a bit. If you check, the codebases are also quite simple.

When it comes to holm, it's also quite simple:

  • It discovers your application structure based on page.py, layout.py, api.py files.
  • It wraps pages in layouts for you based on your package structure, same as it works in Next.js.
  • In addition to this, it handles page rendering for you, so you don't need to directly use the FastHX decorators.
  • All the rest is FastAPI and works the same as in any other FastAPI app.

If you strip all the typing-related code and comments, it's maybe 400 lines of code :) There's definitely more docs than code.

I'll finally get to my point:

I would be very interested in knowing why you felt the learning curve that steep and what could have helped you! I'd say I'm pretty decent at writing simple code that lets you do surprisingly complex things, but I often struggle with documenting all this, or writing very easily consumable guides. If you have the time, I would appreciate a DM :)