#35937: Refactor very similar code of internal dec function for simple_tag,
simple_block_tag and inclusion_tag
-------------------------------------+-------------------------------------
Reporter: Emma Delescolle | Type:
| Cleanup/optimization
Status: new | Component: Template
| system
Version: dev | Severity: Normal
Keywords: | Triage Stage:
decorator,tag,simple_tag | Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
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.
-
https://github.com/django/django/blob/main/django/template/library.py#L111
-
https://github.com/django/django/blob/main/django/template/library.py#L165
-
https://github.com/django/django/blob/main/django/template/library.py#L250
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
--
Ticket URL: <
https://code.djangoproject.com/ticket/35937>
Django <
https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.