-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Introduce a Loop object #4131
Introduce a Loop object #4131
Conversation
a77bad8
to
22071a3
Compare
doc/tags/for.rst
Outdated
implement the ``Countable`` interface. | ||
When the underlying PHP iterator is not countable, the ``loop.length``, | ||
``loop.revindex``, ``loop.revindex0``, and ``loop.last`` variables are not | ||
available and a ``RuntimeException`` is thrown if you retry to use them. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
available and a ``RuntimeException`` is thrown if you retry to use them. | |
available and a ``RuntimeException`` is thrown if you try to use them. |
I just realized that by using a Loop object, assigning it to a different variable (like {% for item in items %}
{% set outer_loop = loop %}
{% for property in item.properties %}
{% for values in property.values %}
{{ outer_loop.index0}} {{property.name}} {{loop.index0}}: {{value}}
{% endfor %}
{% endfor %}
{% endfor %} And this makes it more similar to the way loops work in Jinja (this code snippet would also be valid Jinja code, while |
Fixes #4096