diff options
| author | Mike Edmunds <medmunds@gmail.com> | 2025-07-22 20:40:48 -0700 |
|---|---|---|
| committer | nessita <124304+nessita@users.noreply.github.com> | 2025-07-23 20:17:55 -0300 |
| commit | 55b0cc21310b76ce4018dd793ba50556eaf0af06 (patch) | |
| tree | b56d75363688b6ac34f7e9a773c793d79750104b /django/template | |
| parent | 5527df91921b54b9fd1eb9aca3aabe91ec58a9c7 (diff) | |
Refs #36500 -- Shortened some long docstrings and comments.
Manually reformatted some long docstrings and comments that would be
damaged by the to-be-applied autofixer script, in cases where editorial
judgment seemed necessary for style or wording changes.
Diffstat (limited to 'django/template')
| -rw-r--r-- | django/template/defaulttags.py | 40 | ||||
| -rw-r--r-- | django/template/smartif.py | 5 |
2 files changed, 26 insertions, 19 deletions
diff --git a/django/template/defaulttags.py b/django/template/defaulttags.py index 17a97ec788..98fa43dd69 100644 --- a/django/template/defaulttags.py +++ b/django/template/defaulttags.py @@ -764,7 +764,7 @@ def firstof(parser, token): Or if only some variables should be escaped, you can use:: - {% firstof var1 var2|safe var3 "<strong>fallback value</strong>"|safe %} + {% firstof var1 var2|safe var3 "<strong>fallback</strong>"|safe %} """ bits = token.split_contents()[1:] asvar = None @@ -825,20 +825,21 @@ def do_for(parser, token): The for loop sets a number of variables available within the loop: - ========================== ================================================ - Variable Description - ========================== ================================================ - ``forloop.counter`` The current iteration of the loop (1-indexed) - ``forloop.counter0`` The current iteration of the loop (0-indexed) - ``forloop.revcounter`` The number of iterations from the end of the - loop (1-indexed) - ``forloop.revcounter0`` The number of iterations from the end of the - loop (0-indexed) - ``forloop.first`` True if this is the first time through the loop - ``forloop.last`` True if this is the last time through the loop - ``forloop.parentloop`` For nested loops, this is the loop "above" the - current one - ========================== ================================================ + ======================= ============================================== + Variable Description + ======================= ============================================== + ``forloop.counter`` The current iteration of the loop (1-indexed) + ``forloop.counter0`` The current iteration of the loop (0-indexed) + ``forloop.revcounter`` The number of iterations from the end of the + loop (1-indexed) + ``forloop.revcounter0`` The number of iterations from the end of the + loop (0-indexed) + ``forloop.first`` True if this is the first time through the + loop + ``forloop.last`` True if this is the last time through the loop + ``forloop.parentloop`` For nested loops, this is the loop "above" the + current one + ======================= ============================================== """ bits = token.split_contents() if len(bits) < 4: @@ -1417,7 +1418,11 @@ def url(parser, token): For example, if you have a view ``app_name.views.client_details`` taking the client's id and the corresponding line in a URLconf looks like this:: - path('client/<int:id>/', views.client_details, name='client-detail-view') + path( + 'client/<int:id>/', + views.client_details, + name='client-detail-view', + ) and this app's URLconf is included into the project's URLconf under some path:: @@ -1496,7 +1501,8 @@ def widthratio(parser, token): For example:: <img src="bar.png" alt="Bar" - height="10" width="{% widthratio this_value max_value max_width %}"> + height="10" + width="{% widthratio this_value max_value max_width %}"> If ``this_value`` is 175, ``max_value`` is 200, and ``max_width`` is 100, the image in the above example will be 88 pixels wide diff --git a/django/template/smartif.py b/django/template/smartif.py index c1ed0ff065..da32b38277 100644 --- a/django/template/smartif.py +++ b/django/template/smartif.py @@ -61,8 +61,9 @@ def infix(bp, func): return func(context, self.first, self.second) except Exception: # Templates shouldn't throw exceptions when rendering. We are - # most likely to get exceptions for things like {% if foo in bar - # %} where 'bar' does not support 'in', so default to False + # most likely to get exceptions for things like: + # {% if foo in bar %} + # where 'bar' does not support 'in', so default to False. return False return Operator |
