←back to thread

378 points rbanffy | 1 comments | | HN request time: 0.194s | source
Show context
giancarlostoro ◴[] No.46210692[source]
Template partials look good, which is one of the key reasons frameworks like React are as good and popular as they are, because you can reuse small segments of code.
replies(8): >>46211187 #>>46211247 #>>46211354 #>>46211402 #>>46211982 #>>46212701 #>>46212849 #>>46213424 #
littlecranky67 ◴[] No.46211982[source]
Key benefit for reusability and composability in React is IMHO that they don't use templates at all, but everything is a function.
replies(1): >>46214928 #
globular-toast ◴[] No.46214928[source]
Exactly. There are a few libraries to achieve a similar thing in Python:

* https://htpy.dev/

* https://pypi.org/project/fast_html/

* https://fastht.ml/ (different to above, I think)

* https://github.com/volfpeter/fasthx

Probably others. I strongly prefer this to templating, but I find it makes dyed in the wool Django people squirm.

replies(3): >>46216164 #>>46216606 #>>46216700 #
1. graemep ◴[] No.46216606[source]
iommi is wroth mentioning here. It is different from an HTML generator, but one of the things it does is greatly reduce the amount of HTML you need write.