Opened 12 years ago
Closed 12 years ago
#18888 closed New feature (wontfix)
Block append / prepend template tags
Reported by: | Jonathan Buchanan | Owned by: | nobody |
---|---|---|---|
Component: | Template system | Version: | 1.4 |
Severity: | Normal | Keywords: | template blocks |
Cc: | Triage Stage: | Design decision needed | |
Has patch: | no | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
Add {% append %} and {% prepend %} tags which act the same as {% block %} in a child template, but which implicitly insert {{ block.super }} before or after the child template's block contents, respectively.
I've made use of this feature in Jade and found it nice for blocks which often collect content as they go down the inheritance chain, like script blocks in <head> and before <body>.
It's not so much that having to use {{ block.super }} is annoying or tiresome in any way, but having used them elsewhere, the semantics of append/prepend tags just feel nice in templates.
Change History (2)
comment:1 by , 12 years ago
Triage Stage: | Unreviewed → Design decision needed |
---|
comment:2 by , 12 years ago
Resolution: | → wontfix |
---|---|
Status: | new → closed |
Indeed, per the Zen of Python "There should be one-- and preferably only one --obvious way to do it."
Django's current implementation is very explicit and only slightly more verbose. With your proposal, it isn't clear if the appending/prepending happens from the outer to the inner block, or the other way round.
You can still implement these custom tags in your applications if you like them.
My feeling is that it's not necessary to have two ways of appending and prepending content to a block. People who really want that sort of thing can use third-party apps like django-sekizai.