Project

General

Profile

Actions

Bug #84157

closed

iterator.isLast does not work correctly - sorry! Working as expected! Please delete!

Added by Gone With the Wind over 6 years ago. Updated over 6 years ago.

Status:
Rejected
Priority:
Should have
Assignee:
-
Category:
Fluid
Target version:
Start date:
2018-03-07
Due date:
% Done:

0%

Estimated time:
TYPO3 Version:
8
PHP Version:
7.1
Tags:
for viewhelper, isLast
Complexity:
Is Regression:
Sprint Focus:

Description

From what I understand, the "isLast" param is a boolean compared again "total":

// FluidTypo3: "For" viewhelper, lines 124ff:
if (isset($arguments['iteration'])) {
    $iterationData['isFirst'] = $iterationData['cycle'] === 1;
    $iterationData['isLast'] = $iterationData['cycle'] === $iterationData['total'];      <-- here!
    $iterationData['isEven'] = $iterationData['cycle'] % 2 === 0;
    $iterationData['isOdd'] = !$iterationData['isEven'];
    $templateVariableContainer->add($arguments['iteration'], $iterationData);
    $iterationData['index']++;
    $iterationData['cycle']++;
}

But this:

<f:spaceless>
<f:for each="{person.roles}" as="role" iteration="i">
    <f:if condition="{i.isFirst}">(</f:if>{i.index} - {role.name} (total: {i.total}, isFirst: {i.isFirst}, isLast: {i.isLast})<f:if condition="{i.cycle} < {i.total}">,&nbsp;</f:if>
    <f:if condition="{i.isLast}">)</f:if>
</f:for>
</f:spaceless>

results into this:

(0 - Cook (total: 2, isFirst: 1, isLast: ),  1 - waiter(total: 2, isFirst: , isLast: 1) )

On the first iteration, isLast is empty, which seems to be interpreted as "true", therefore the closing parenthesis is set - which is wrong.

On a side note:
Shouldn't <f:spaceless> remove the whitespace between the </f:if> <f:if> within the loop? It does not and instead prints the whitespace...

Actions #1

Updated by Gone With the Wind over 6 years ago

  • Subject changed from iterator.isLast does not work correctly to iterator.isLast does not work correctly - sorry! Working as expected! Please delete!

No, sorry! My fault! Working as expected!
Please delete this issue!

Actions #2

Updated by Wouter Wolters over 6 years ago

  • Status changed from New to Rejected

Closed as requested.

Actions

Also available in: Atom PDF