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
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
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
htpyis still fairly minimal. But here are some very early thoughts:htpyover 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__(...)inhtpyat first, but it also pairs nicely with web components.htpy.Elements 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).Fragmentclass to allow me to render non-nested HTML. This is useful in a few places, like HTMX responses that use oob swaps. It feels likeFragmentcould actually be the class thathtpy.Elementderives from: it's a container for children but without an explicit parent tag/attributes.htpy.Nodecould then referenceFragmentinstead ofElement. (Fragmentis distinguished from a list ofElementin thatstr(some_fragment)will render HTML, whilestr([element_1(), element_2(), ...])won't.htpyalso 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