Opened 2 years ago

Closed 9 months ago

#20435 closed Cleanup/optimization (fixed)

Reorder template tag documentation.

Reported by: jonathanslenders Owned by: danielr
Component: Documentation Version: master
Severity: Normal Keywords:
Cc: timograham@… Triage Stage: Accepted
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

Right now, the documentation for creation of custom template tags, using a (parser, token)-function, is mentioned above the creation of simple template tags.
It would be great to revert this order, and make clear that when possible a simple tag is recommended. (Not only for readability.)

Why?:
The ability of creating custom template tags using (parser, token) is great, but it's a lot harder or impossible to predict the behaviour or the change the template render engine if we ever have to in the future. Making sure that people are using as much as possible the built-in Node classes, would do for a nice abstract syntax tree in moste cases.

https://docs.djangoproject.com/en/dev/howto/custom-template-tags/

See this ticket #20434 for related info.

Change History (8)

comment:1 Changed 2 years ago by aaugustin

  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset
  • Triage Stage changed from Unreviewed to Accepted
  • Version set to master

That proposal makes sense to me.

comment:2 Changed 2 years ago by zerok

I definitely agree. We should encourage people to put far more logic into template tags and filters than in the templates themselves. Having the most complicated approach being mentioned first, doesn't help.

comment:3 Changed 2 years ago by danielquinn

  • Owner changed from nobody to danielquinn
  • Status changed from new to assigned

comment:4 Changed 2 years ago by danielquinn

https://github.com/django/django/pull/1125

Basically I broke the whole tags section up into "Simple" and "Advanced", placing the simple stuff first.

comment:5 Changed 2 years ago by timo

  • Cc timograham@… added
  • Has patch set
  • Patch needs improvement set

Existing pull request doesn't merge cleanly due to some recent commits.

comment:6 Changed 9 months ago by danielr

  • Owner changed from danielquinn to danielr

comment:7 Changed 9 months ago by danielr

  • Patch needs improvement unset

comment:8 Changed 9 months ago by Julien Phalip <jphalip@…>

  • Resolution set to fixed
  • Status changed from assigned to closed

In 524e71c9c20da57722b22b978d87690379ca4ade:

Fixed #20435 -- Reordered the custom template tags docs.

Introduced the various shortcuts before explaining the more complex
parser/render functionality.

Also removed non-decorator syntax: it's been years since Django
supported a Python version without decorators.

Note: See TracTickets for help on using tickets.
Back to Top