←back to thread

378 points rbanffy | 5 comments | | HN request time: 0.613s | 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 #
agumonkey ◴[] No.46211247[source]
indeed the vintage templating was a logical bottleneck
replies(1): >>46211347 #
1. f311a ◴[] No.46211347[source]
How is it different from include? Just less files from my perspective
replies(3): >>46211378 #>>46211408 #>>46214371 #
2. simonw ◴[] No.46211378[source]
The "inline partials" feature is neat, means you can use and define a partial at the same time.

The way you can render just a named partial from both the render() shortcut and the include tag is nice too:

https://docs.djangoproject.com/en/6.0/ref/templates/language...

replies(1): >>46211495 #
3. chistev ◴[] No.46211408[source]
I asked the same question
4. f311a ◴[] No.46211495[source]
Yeah, but I was doing the same thing 10 years ago with include mixed with extends and blocks. I can just include a file inside a template or render it directly.
5. agumonkey ◴[] No.46214371[source]
you're kinda right, {% partial ... %} vs {% include ... %} is not a big difference, but my mind was vaguely thinking that "includes" have often been seen as large templates, whereas partial have been after the component era with the idea of making small blocks. (my 2 cents)