-
-
Notifications
You must be signed in to change notification settings - Fork 106
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
tests: added test for snippet & block
- Loading branch information
Showing
3 changed files
with
93 additions
and
0 deletions.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
<?php | ||
|
||
use Tester\Assert; | ||
|
||
|
||
require __DIR__ . '/../bootstrap.php'; | ||
|
||
|
||
$latte = new Latte\Engine; | ||
|
||
Assert::matchFile( | ||
__DIR__ . '/expected/UIMacros.snippet4.phtml', | ||
$latte->compile(__DIR__ . '/templates/snippets.block.latte') | ||
); |
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,67 @@ | ||
<?php | ||
// source: %A% | ||
|
||
class Template%a% extends Latte\Template | ||
{ | ||
public $_blocks = [ | ||
'_snippet' => 'block__snippet_142fc55', | ||
'block1' => 'block_block1_9dd085e', | ||
'_outer' => 'block__outer_b1d040b', | ||
'block2' => 'block_block2_e0d89d3', | ||
]; | ||
|
||
|
||
function render() | ||
{ | ||
%A% | ||
$_l->extends = empty($_g->extended) && isset($_control) && $_control instanceof Nette\Application\UI\Presenter ? $_control->findLayoutTemplateFile() : NULL; $_g->extended = TRUE; | ||
|
||
if ($_l->extends) { ob_start(function () {});} | ||
|
||
// main template | ||
if ($_l->extends) { ob_end_clean(); return $this->renderChildTemplate($_l->extends, get_defined_vars()); } | ||
call_user_func(reset($_b->blocks['_snippet']), $_b, $this->params) ?> | ||
|
||
|
||
<div id="<?php echo $_control->getSnippetId('outer') ?>"><?php call_user_func(reset($_b->blocks['_outer']), $_b, $this->params) ?> | ||
</div><?php | ||
} | ||
|
||
|
||
function block__snippet_%h%($_b, $_args) | ||
{ | ||
unset($_args["this"]); foreach ($_args as $__k => $__v) $$__k = $__v; | ||
$_control->redrawControl('snippet', FALSE); | ||
|
||
|
||
} | ||
|
||
|
||
function block_block1_%h%($_b, $_args) | ||
{ | ||
?><div<?php echo ' id="' . $_control->getSnippetId('snippet') . '"' ?>> | ||
static | ||
</div> | ||
<?php | ||
} | ||
|
||
|
||
function block__outer_%h%($_b, $_args) | ||
{ | ||
unset($_args["this"]); foreach ($_args as $__k => $__v) $$__k = $__v; | ||
$_control->redrawControl('outer', FALSE) | ||
?>begin | ||
end | ||
<?php if (isset($_l->dynSnippets)) return $_l->dynSnippets; | ||
} | ||
|
||
|
||
function block_block2_%h%($_b, $_args) | ||
{ | ||
?><div<?php echo ' id="' . ($_l->dynSnippetId = $_control->getSnippetId("inner-$id")) . '"' ?>> | ||
dynamic | ||
</div> | ||
<?php | ||
} | ||
|
||
} |
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,12 @@ | ||
<div n:snippet="snippet" n:block="block1"> | ||
static | ||
</div> | ||
|
||
|
||
{snippet outer} | ||
begin | ||
<div n:snippet="inner-$id" n:block="block2"> | ||
dynamic | ||
</div> | ||
end | ||
{/snippet} |