Skip to content

Update templating.rst #6869

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

Closed
wants to merge 2 commits into from
Closed

Update templating.rst #6869

wants to merge 2 commits into from

Conversation

asandjivy
Copy link
Contributor

Fixed bad div tags count

Fixed bad div tags count
@wouterj
Copy link
Member

wouterj commented Aug 12, 2016

Wow, amazing catch!

However, instead of making it a bit more complex (11 is more complex than 10), what about changing the code instead?

- {% for i in 0..10 %}
-   <div class="{{ cycle(['odd', 'even'], i) }}">
+ {% for i in 1..10 %}
+   <div class="{{ cycle(['even', 'odd'], i) }}">
      <!-- some HTML here -->
    </div>
  {% endfor %}

@asandjivy
Copy link
Contributor Author

Yes i thought about it.
But maybe just to specify that it is possible to count from 0 and the result is 11.
If you prefer to start from 1, no problem ;)

@asandjivy
Copy link
Contributor Author

asandjivy commented Aug 12, 2016

My friend suggests: for i in 0 .. 9

@wouterj
Copy link
Member

wouterj commented Aug 14, 2016

0 .. 9 is fine for me as well, although I think 1 .. 10 is the most explaining (you can just look at the last number and know how many times the element is printed).

Please note that we're specificly documenting Symfony here, not Twig. So we don't have to document the possibility to count from 0, that's up to Twig's docs.

@asandjivy
Copy link
Contributor Author

ok fine ;) let's go for 1 .. 10

@wouterj
Copy link
Member

wouterj commented Aug 17, 2016

👍
status: reviewed

Thanks!

@weaverryan
Copy link
Member

Great catch @asandjivy! And I also like the solution that you ended with. Thanks!

weaverryan added a commit that referenced this pull request Aug 21, 2016
This PR was submitted for the 3.1 branch but it was merged into the 2.7 branch instead (closes #6869).

Discussion
----------

Update templating.rst

Fixed bad div tags count

Commits
-------

93cb1d1 Update templating.rst
db04559 Update templating.rst
@weaverryan weaverryan closed this Aug 21, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants