#18888 closed New feature (wontfix)

Block append / prepend template tags

Reported by: insin 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


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.

Attachments (0)

Change History (2)

comment:1 Changed 20 months ago by harrislapiroff

  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset
  • Triage Stage changed from Unreviewed to Design decision needed

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.

comment:2 Changed 20 months ago by aaugustin

  • Resolution set to wontfix
  • Status changed from new to 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.

Add Comment

Modify Ticket

Change Properties
<Author field>
as closed
as The resolution will be set. Next status will be 'closed'
The resolution will be deleted. Next status will be 'new'

E-mail address and user name can be saved in the Preferences.

Note: See TracTickets for help on using tickets.