Skip to content

Commit

Permalink
Fix #913
Browse files Browse the repository at this point in the history
  • Loading branch information
d-maurer committed Oct 9, 2020
1 parent 6e96a9a commit d58e3c0
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 2 deletions.
3 changes: 3 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ https://zope.readthedocs.io/en/2.13/CHANGES.html
4.5.2 (unreleased)
------------------

- Fix ``length`` for page template repeat variables
(`#913 <https://github.com/zopefoundation/Zope/issues/913>`_)

- Restore the ZMI `Debug Information` control panel page
(`#898 <https://github.com/zopefoundation/Zope/issues/898>`_)

Expand Down
3 changes: 1 addition & 2 deletions src/Products/PageTemplates/engine.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,10 +78,9 @@ def __call__(self, key, iterable):
iterable = list(iterable) if iterable is not None else ()

length = len(iterable)
iterator = iter(iterable)

# Insert as repeat item
ri = self[key] = RepeatItem(None, iterator, _PseudoContext)
ri = self[key] = RepeatItem(None, iterable, _PseudoContext)

return ri, length

Expand Down
1 change: 1 addition & 0 deletions src/Products/PageTemplates/tests/input/RepeatVariable.html
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
<li tal:content="string:Roman: ${repeat/item/Roman}"/>
<li tal:content="string:start: ${repeat/item/start}"/>
<li tal:content="string:end: ${repeat/item/end}"/>
<li tal:content="string:length: ${repeat/item/length}"/>
</tal:block>
</ol>
</body>
Expand Down
5 changes: 5 additions & 0 deletions src/Products/PageTemplates/tests/output/RepeatVariable.html
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
<li>Roman: I</li>
<li>start: True</li>
<li>end: False</li>
<li>length: 5</li>

<li>index: 1</li>
<li>number: 2</li>
Expand All @@ -25,6 +26,7 @@
<li>Roman: II</li>
<li>start: False</li>
<li>end: False</li>
<li>length: 5</li>

<li>index: 2</li>
<li>number: 3</li>
Expand All @@ -37,6 +39,7 @@
<li>Roman: III</li>
<li>start: False</li>
<li>end: False</li>
<li>length: 5</li>

<li>index: 3</li>
<li>number: 4</li>
Expand All @@ -49,6 +52,7 @@
<li>Roman: IV</li>
<li>start: False</li>
<li>end: False</li>
<li>length: 5</li>

<li>index: 4</li>
<li>number: 5</li>
Expand All @@ -61,6 +65,7 @@
<li>Roman: V</li>
<li>start: False</li>
<li>end: True</li>
<li>length: 5</li>

</ol>
</body>
Expand Down

0 comments on commit d58e3c0

Please sign in to comment.