Opened 2 hours ago

Closed 2 hours ago

#35937 closed Cleanup/optimization (wontfix)

Refactor very similar code of internal dec function for simple_tag, simple_block_tag and inclusion_tag

Reported by: Emma Delescolle Owned by:
Component: Template system Version: dev
Severity: Normal Keywords: decorator, tag, simple_tag
Cc: Emma Delescolle Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

The internal dec function used by simple_tag, simple_block_tag and inclusion_tag are very similar. There are also similarities in the process of determining the return value of these methods (the decorated function or the decorator itself). These similarities should be refactored.

Refactoring this function to be either a method of the Library class they are defined in or as a completely separate function would:

  • reduce the amount of code to maintain
  • render change easier if anything ever has to change inside those
  • allow the end-user to use that function/method to create their own complex template tags

Change History (1)

comment:1 by David Sanders, 2 hours ago

Resolution: wontfix
Status: newclosed

Hi & thanks for your interest in helping out with Django.

The Django codebase usually tends to follow the WET (Write Everything Twice/Thrice) and in the case you've highlighted there doesn't appear to be a major advantage in modifying code to risk reducing readability and/or introduce regressions.

Will close the ticket for now but if you disagree feel free to head over to the Django Forum to start a discussion 👍

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