Skip to content
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

Add {{ loop.odd? }} and {{ loop.even? }} properties to the for loop variable #201

Open
ellmetha opened this issue Mar 5, 2024 · 0 comments

Comments

@ellmetha
Copy link
Member

ellmetha commented Mar 5, 2024

Description

In order to make it easier to implement specific templates with for loops, let's ensure that the loop contextual variable also provides odd? and even? attributes.

For example:

{% for x in items %}
  {% if loop.even? %}
    Do something...
  {% else %}
    Do something else...
  {% endif %{
{% endfor %}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

No branches or pull requests

1 participant