Invalidating dynamic snippets with {include template} is broken

Notice: This thread is very old.
Pavel Janda
Member | 977
+
0
-

Hi,

I will start with an example.

1, Start with nette/web-project
2, Add jquery and nette.ajax.js.
3, Presenter:

class HomepagePresenter extends Nette\Application\UI\Presenter
{

	public function renderDefault()
	{
		if (!isset($this->template->items)) {
			$this->template->items = [['id' => 1, 'name' => 'a'], ['id' => 2, 'name' => 'b']];
		}
	}


	public function handleA()
	{
		$this->template->items = [['id' => 1, 'name' => 'c']];
		$this->redrawControl('data');
	}

}

4, Little template t.latte:

{$param}

5, Homepage template:

{block content}
	<table border="1">
		<thead>
			<!-- never redraw thead! -->
		</thead>
		<tbody n:snippet="tbody">
			{snippetArea data}
				{foreach $items as $item}
					{var $id = $item['id']}
					<tr n:snippet="data-$id">
						<td>
							{* {include 't.latte', param => $item['name']} *}
							{$item['name']}
						</td>
					</tr>
				{/foreach}
			{/snippetArea}
		</tbody>
	</table>

	<a class="ajax" n:href="a!">Do stuff!</a>
{/block}

Now, that works fine, when you click on Do stuff, instead of a the template shows c.
But if i instead of direct output include an template with same value, the invalidation brokes down:

{block content}
	<table border="1">
		<thead>
			<!-- never redraw thead! -->
		</thead>
		<tbody n:snippet="tbody">
			{snippetArea data}
				{foreach $items as $item}
					{var $id = $item['id']}
					<tr n:snippet="data-$id">
						<td>
							{include 't.latte', param => $item['name']}
							{* {$item['name']} *}
						</td>
					</tr>
				{/foreach}
			{/snippetArea}
		</tbody>
	</table>

	<a class="ajax" n:href="a!">Do stuff!</a>
{/block}

Now when you click the link, instead of c there is nothing.

Last edited by Pavel Janda (2016-01-14 17:48)