Skip to content

Commit

Permalink
tests: dynamic snippetArea with included template [ref nette/latte#95]
Browse files Browse the repository at this point in the history
  • Loading branch information
matej21 authored and dg committed Jan 20, 2016
1 parent 2c2b7e3 commit 84d309d
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 1 deletion.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
"nette/di": "~2.3",
"nette/forms": "~2.2",
"nette/robot-loader": "~2.2",
"latte/latte": "~2.3.0"
"latte/latte": "~2.3.9"
},
"conflict": {
"nette/nette": "<2.2"
Expand Down
37 changes: 37 additions & 0 deletions tests/Bridges.Latte/UIMacros.renderSnippets3.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
<?php

/**
* Test: UIMacros, renderSnippets and dynamic snippetArea with included template
*/

use Nette\Bridges\ApplicationLatte\UIMacros;
use Tester\Assert;


require __DIR__ . '/../bootstrap.php';

class TestPresenter extends Nette\Application\UI\Presenter
{

public function render()
{
$latte = new Latte\Engine;
UIMacros::install($latte->getCompiler());
$params['_control'] = $this;
$latte->setTempDirectory(__DIR__ . '/../tmp/');
$latte->render(__DIR__ . '/templates/snippetArea-include.latte', $params);
}
}


$presenter = new TestPresenter;
$presenter->snippetMode = TRUE;
$presenter->redrawControl('foo');
$presenter->redrawControl('data');
$presenter->render();
Assert::same(array(
'snippets' => array(
'snippet--bar-1' => "1\n",
'snippet--bar-2' => "2\n",
),
), (array) $presenter->payload);
5 changes: 5 additions & 0 deletions tests/Bridges.Latte/templates/snippetArea-include.latte
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{snippetArea foo}
{foreach [1, 2] as $id}
{snippet bar-$id}{include 'snippetArea-included.latte' id => $id}{/snippet}
{/foreach}
{/snippetArea}
1 change: 1 addition & 0 deletions tests/Bridges.Latte/templates/snippetArea-included.latte
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{$id}

0 comments on commit 84d309d

Please sign in to comment.