Skip to content

Commit 70f974a

Browse files
committed
Merge pull request #133 from matej21/fix/variabletemplate
Latte bridge: fixed missing $template variable
2 parents 633874b + a84ea1e commit 70f974a

File tree

6 files changed

+28
-1
lines changed

6 files changed

+28
-1
lines changed

src/Bridges/ApplicationLatte/UIMacros.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ public function initialize()
6060
*/
6161
public function finalize()
6262
{
63-
return ['if (Nette\Bridges\ApplicationLatte\UIRuntime::initialize($this, $this->blockQueue)) return;', ''];
63+
return ['if (Nette\Bridges\ApplicationLatte\UIRuntime::initialize($this, $this->blockQueue)) return; $template = $this->params["template"];', ''];
6464
}
6565

6666

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
<?php
2+
3+
/**
4+
* VariableTemplate
5+
*/
6+
7+
use Nette\Bridges\ApplicationLatte\UIMacros;
8+
use Tester\Assert;
9+
10+
11+
require __DIR__ . '/../bootstrap.php';
12+
13+
14+
class TestPresenter extends Nette\Application\UI\Presenter
15+
{
16+
17+
}
18+
19+
20+
$latte = new Latte\Engine;
21+
$latte->setLoader(new Latte\Loaders\StringLoader());
22+
UIMacros::install($latte->getCompiler());
23+
Assert::match('3', $latte->renderToString('{$template->length($bar)}', ['bar' => 'aaa', '_control' => new TestPresenter()]));

tests/Bridges.Latte/expected/UIMacros.dynamicsnippets.alt.phtml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ class Template%a% extends Latte\Template
1414
%A%
1515
// prolog Nette\Bridges\ApplicationLatte\UIMacros
1616
if (Nette\Bridges\ApplicationLatte\UIRuntime::initialize($this, $this->blockQueue)) return;
17+
$template = $this->params["template"];
1718

1819
// main template
1920
if ($this->tryRenderParent(get_defined_vars())) return;

tests/Bridges.Latte/expected/UIMacros.dynamicsnippets.phtml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ class Template%a% extends Latte\Template
1313
%A%
1414
// prolog Nette\Bridges\ApplicationLatte\UIMacros
1515
if (Nette\Bridges\ApplicationLatte\UIRuntime::initialize($this, $this->blockQueue)) return;
16+
$template = $this->params["template"];
1617

1718
// main template
1819
if ($this->tryRenderParent(get_defined_vars())) return;

tests/Bridges.Latte/expected/UIMacros.snippet.alt.phtml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ class Template%a% extends Latte\Template
1515
%A%
1616
// prolog Nette\Bridges\ApplicationLatte\UIMacros
1717
if (Nette\Bridges\ApplicationLatte\UIRuntime::initialize($this, $this->blockQueue)) return;
18+
$template = $this->params["template"];
1819

1920
// main template
2021
?> <div class="test"<?php echo ' id="' . $_control->getSnippetId('outer') . '"' ?>>

tests/Bridges.Latte/expected/UIMacros.snippet.phtml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ class Template%a% extends Latte\Template
1717
%A%
1818
// prolog Nette\Bridges\ApplicationLatte\UIMacros
1919
if (Nette\Bridges\ApplicationLatte\UIRuntime::initialize($this, $this->blockQueue)) return;
20+
$template = $this->params["template"];
2021

2122
// main template
2223
if ($this->tryRenderParent(get_defined_vars())) return;

0 commit comments

Comments
 (0)