-
-
Notifications
You must be signed in to change notification settings - Fork 108
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
157 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,60 @@ | ||
<?php | ||
|
||
/** | ||
* Test: variable scope | ||
*/ | ||
|
||
declare(strict_types=1); | ||
|
||
use Tester\Assert; | ||
|
||
|
||
require __DIR__ . '/../bootstrap.php'; | ||
|
||
|
||
$latte = new Latte\Engine; | ||
$latte->setLoader(new Latte\Loaders\StringLoader); | ||
|
||
$template = <<<'XX' | ||
{var $var = a} | ||
{define a} | ||
{$var} | ||
{var $var = define} | ||
{/define} | ||
{$var} | ||
{block b} | ||
{$var} | ||
{var $var = blocknamed} | ||
{/block} | ||
{$var} | ||
{block|trim} | ||
{$var} | ||
{var $var = blockmod} | ||
{/block} | ||
{$var} | ||
{block} | ||
{$var} | ||
{var $var = block} | ||
{/block} | ||
{$var} | ||
XX; | ||
|
||
Assert::matchFile( | ||
__DIR__ . '/expected/BlockMacros.vars.phtml', | ||
$latte->compile($template) | ||
); | ||
Assert::matchFile( | ||
__DIR__ . '/expected/BlockMacros.vars.html', | ||
$latte->renderToString($template) | ||
); |
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,20 @@ | ||
|
||
|
||
a | ||
|
||
|
||
a | ||
|
||
|
||
a | ||
|
||
|
||
a | ||
|
||
blockmod | ||
|
||
|
||
blockmod | ||
|
||
|
||
block |
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,73 @@ | ||
<?php | ||
%A% | ||
$var = 'a' /* line %d% */; | ||
echo "\n"; | ||
if ($this->getParentName()) { | ||
return get_defined_vars(); | ||
} | ||
echo "\n"; | ||
echo LR\Filters::escapeHtmlText($var) /* line %d% */; | ||
echo ' | ||
'; | ||
$this->renderBlock('b', get_defined_vars()) /* line %d% */; | ||
echo ' | ||
'; | ||
echo LR\Filters::escapeHtmlText($var) /* line %d% */; | ||
echo ' | ||
'; | ||
ob_start(function () {}) /* line %d% */; | ||
echo ' '; | ||
echo LR\Filters::escapeHtmlText($var) /* line %d% */; | ||
echo "\n"; | ||
$var = 'blockmod' /* line %d% */; | ||
$ʟ_fi = new LR\FilterInfo('html'); | ||
echo LR\Filters::convertTo($ʟ_fi, 'html', $this->filters->filterContent('trim', $ʟ_fi, ob_get_clean())); | ||
echo ' | ||
'; | ||
echo LR\Filters::escapeHtmlText($var) /* line %d% */; | ||
echo ' | ||
'; | ||
echo LR\Filters::escapeHtmlText($var) /* line %d% */; | ||
echo "\n"; | ||
$var = 'block' /* line %d% */; | ||
echo ' | ||
'; | ||
echo LR\Filters::escapeHtmlText($var) /* line %d% */; | ||
return get_defined_vars(); | ||
} | ||
|
||
|
||
/** {define a} on line %d% */ | ||
public function blockA(array $ʟ_args): void | ||
{ | ||
extract($this->params); | ||
extract($ʟ_args); | ||
echo ' '; | ||
echo LR\Filters::escapeHtmlText($var) /* line %d% */; | ||
echo "\n"; | ||
$var = 'define' /* line %d% */; | ||
|
||
} | ||
|
||
|
||
/** {block b} on line %d% */ | ||
public function blockB(array $ʟ_args): void | ||
{ | ||
extract($this->params); | ||
extract($ʟ_args); | ||
echo ' '; | ||
echo LR\Filters::escapeHtmlText($var) /* line %d% */; | ||
echo "\n"; | ||
$var = 'blocknamed' /* line %d% */; | ||
|
||
} | ||
%A% |