Add loop.changed, loop.previous, loop.next, and loop.cycle variables#4135
Merged
Conversation
b92496e to
65b4ea4
Compare
stof
reviewed
Jul 12, 2024
| {{ loop.index }} - {{ user.username }} | ||
| {% endfor %} | ||
|
|
||
| Use ``loop.cycle`` to cycle among a list of values: |
Member
There was a problem hiding this comment.
Do we need to add this one give we already implemented the standalone cycle filter (that was added later in Jinja) ?
Contributor
Author
There was a problem hiding this comment.
It's a shortcut. Maybe it's not needed, but I find it nice to not have to care about the second arg.
| @@ -55,9 +55,9 @@ The ``loop`` variable | |||
|
|
|||
| Inside of a ``for`` loop block you can access some special variables: | |||
Member
There was a problem hiding this comment.
Describing loop.changed as a variable looks weird to me, as changed is not a getter but a method requiring an argument.
Anyway, from a strict point of view, there is only 1 special variable: loop. What this table describes is the API of this loop variable.
34dfb04 to
55b414c
Compare
stof
approved these changes
Jul 12, 2024
willrowe
reviewed
Jul 18, 2024
| ``loop.cycle`` Cycle over a sequence of values | ||
| ``loop.changed`` True if previously called with a different value or if not called yet | ||
| ``loop.previous`` The value from the previous iteration (``null`` for the first iteration) | ||
| ``loop.next`` The value from the next iteration (``null`` for the first iteration) |
Contributor
There was a problem hiding this comment.
-``loop.next`` The value from the next iteration (``null`` for the first iteration)
+``loop.next`` The value from the next iteration (``null`` for the last iteration)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.