logoalt Hacker News

giancarlostoroyesterday at 9:10 PM8 repliesview on HN

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

littlecranky67yesterday at 11:07 PM

Key benefit for reusability and composability in React is IMHO that they don't use templates at all, but everything is a function.

show 1 reply
apothegmtoday at 1:07 AM

The most obvious value here is for HTMX, which requires a lot of partial templates.

squidsoupyesterday at 9:49 PM

React allows for encapsulation of state in a reusable component, its more than just templating.

simonwyesterday at 10:02 PM

They're a neat design. I started using them on my blog the other day as part of trying out Django 6: https://github.com/simonw/simonwillisonblog/blob/faec3532183...

pier25today at 2:44 AM

Amazing that Django didn't have this until 2025

show 1 reply
chistevyesterday at 10:06 PM

But you could already reuse templates in Django by including them. What am I missing?

show 3 replies
agumonkeyyesterday at 9:53 PM

indeed the vintage templating was a logical bottleneck

show 1 reply
wahnfriedentoday at 12:46 AM

There've been a variety of open source attempts at this idea. Is this official one now the best to use, or are the others still compelling?

show 1 reply