Comment by giancarlostoro

13 hours ago

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.

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

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

  • React also requires you to know the long list of do's and dont's and is littered with minefields that most average developers are not even aware of.

    Everyone just busts out "React" for every small thing, but few commit to actually learning this pretty complicated technology.

    The last two recent Cloudflare outages were because of React.

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

  • Partialdef inline is the real win. Lets you define parts of a page without needing to place them in another file. Reduces the mental overhead of imagining how the inclusion will look because it’s already there.

    The use case is mainly driven by htmx where you will have lots of these partials and the view code renders them as individual responses.

  • It's just syntactic sugar, making life a bit easier for HTMX users (cf. "htmx was the main motivation for this feature").

    I'm using Unpoly and I just render the whole page and let Unpoly swap the content according to the target selectors, so no need for this. Not much difference in perf if you dont generate gigantic pages with heavy header/footer.

indeed the vintage templating was a logical bottleneck