bug in latte {ifchanged }?
- thcom
- Backer | 94
may be i am blind, but i think it is bug
clean project with create-project nette/web-project test
renderDefault –
function renderDefault() {
$data = [];
function addData($id) {
$item = new Nette\Utils\ArrayHash;
$item->id = $id * 10;
$item->flag = intdiv($id,3);
$item->name = "Name $id";
return $item;
}
for ($x = 1; $x<15; $x++)
$data[$x] = addData($x);
dump($data);
$this->template->data = $data;
}
default.latte
{* This is the w/lcome page, you can delete it *}
{block content}
<style>
table {
border: 1px solid #006699;
border-collapse:collapse;
}
table td, table th {
border: 1px solid #006699;
padding: 5px 5px 5px 5px;
text-align: center;
</style>
<table>
<tr>
<th> first
<th> id
<th> flag
<th> name
<th> flg changed
{foreach $data as $item}
<tr>
{if !$iterator->first}
{ifchanged $item->flag}
<td colspan="5"> separator {ifchanged $item->flag} Y {/ifchanged}
<tr>
{/ifchanged}
{/if}
<td> {if !$iterator->first} A {else} N {/if}
<td> {$item->id}
<td> {$item->flag}
<td> {$item->name}
<td> changed: {ifchanged $item->flag} Y {/ifchanged}
<br>
{/foreach}
I thing the first does not have to be there