Replies: 1 comment 1 reply
-
Thanks a lot for sharing this write up, it is really useful and I am happy that htpy is useful to you!
|
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Thanks for this handy library.
I had a chance to use it in a new project, voterbowl.org. We're running campaigns to encourage college students in the US to check their voter registration in advance of the 2024 presidential election. To give a sense of what it looks like:
VoterBowl came together pretty quickly, and is relatively small, so my experience with
htpy
is still fairly minimal. But here are some very early thoughts:htpy
over Django templates; in fact, an early version of the site used Django templates and I converted it. Overall, I find the new code easier to reason about; the ability to use Python type hints throughout, particularly for individual components in my design, feels like a real win.__getitem__
for children.__getattr__(...)
inhtpy
at first, but it also pairs nicely with web components.htpy.Element
s but can have more complex trees before nesting their children. (I settled on a pattern like the one suggested in [Idea] allow repeated attribute extension! #6).Fragment
class to allow me to render non-nested HTML. This is useful in a few places, like HTMX responses that use oob swaps. It feels likeFragment
could actually be the class thathtpy.Element
derives from: it's a container for children but without an explicit parent tag/attributes.htpy.Node
could then referenceFragment
instead ofElement
. (Fragment
is distinguished from a list ofElement
in thatstr(some_fragment)
will render HTML, whilestr([element_1(), element_2(), ...])
won't.htpy
also requires me to be very careful with whitespace characters; it's a bit awkward in places. This reminds me of the javascript templating world just before JSX became mainstream; not really an issue with htpy, but it would be fun to see the community resurrect and build tooling around something like Guido's pyxl.Thanks again for
htpy
!Beta Was this translation helpful? Give feedback.
All reactions