[2.1dev] Latte {continueIf} macro behavior
Notice: This thread is very old.
- Mysteria
- Member | 797
Nette Framework 2.1dev (revision c0af0e6 released on 2013–05–20)
Latte code:
<?php
<tbody n:inner-foreach='$punishments as $punishment'>
{continueIf !$punishment[active]}
<tr>
<td>{$punishment[id]}</td>
</tr>
</tbody>
?>
Generated PHP code:
<?php
$iterations = 0; foreach ($punishments as $punishment): if (!$punishment['active']) { echo "</tbody>\n"; continue; }
?>
Generated HTML Code:
<?php
<tbody>
</tbody>
</tbody>
</tbody>
</tbody>
</tbody>
</tbody>
</tbody>
</tbody>
</tbody>
</tbody>
</tbody>
</tbody>
</tbody>
</tbody>
</tbody>
?>
Question is why {continueIf} macro always close that </tbody> tag? This generate bad HTML code.
I am not sure if this is bug, but when I open CoreMacros.php, line 259:
<?php
return $writer->write("if (%node.args) { echo \"</{$node->parentNode->htmlNode->name}>\\n\"; $cmd; }");
?>
and rewrite it to
<?php
return $writer->write("if (%node.args) { $cmd; }");
?>
{continueIf} not close </tbody> tag and generate good HTML code.
Last edited by Mysteria (2013-05-30 16:19)