-
-
Notifications
You must be signed in to change notification settings - Fork 107
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
SnippetBridge: added setSnippetMode; added snippet test (#150)
- Loading branch information
Showing
3 changed files
with
56 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
<?php | ||
|
||
/** | ||
* Test: UIMacros, renderSnippets and template rendered from another template | ||
*/ | ||
|
||
use Nette\Bridges\ApplicationLatte\UIMacros; | ||
use Nette\Bridges\ApplicationLatte\SnippetBridge; | ||
use Tester\Assert; | ||
|
||
|
||
require __DIR__ . '/../bootstrap.php'; | ||
|
||
|
||
|
||
class TestPresenter extends Nette\Application\UI\Presenter | ||
{ | ||
|
||
public function render() | ||
{ | ||
$latte = new Latte\Engine; | ||
$latte->setLoader(new Latte\Loaders\StringLoader); | ||
UIMacros::install($latte->getCompiler()); | ||
$latte->addProvider('uiControl', $this); | ||
$latte->addProvider('snippetBridge', new SnippetBridge($this)); | ||
$latte->render('{snippet foo}{php $presenter->renderFoo()}{/snippet}', ['presenter' => $this]); | ||
} | ||
|
||
public function renderFoo() | ||
{ | ||
$latte = new Latte\Engine; | ||
$latte->setLoader(new Latte\Loaders\StringLoader); | ||
UIMacros::install($latte->getCompiler()); | ||
$latte->addProvider('uiControl', $this); | ||
$latte->addProvider('snippetBridge', new SnippetBridge($this)); | ||
$latte->render('Hello'); | ||
} | ||
} | ||
|
||
|
||
$presenter = new TestPresenter; | ||
$presenter->snippetMode = TRUE; | ||
$presenter->redrawControl('foo'); | ||
$presenter->render(); | ||
Assert::same([ | ||
'snippets' => [ | ||
'snippet--foo' => 'Hello', | ||
], | ||
], (array) $presenter->payload); |