diff --git a/composer.json b/composer.json index 8a89de639..0175c0e39 100644 --- a/composer.json +++ b/composer.json @@ -30,7 +30,7 @@ "nette/forms": "~2.4", "nette/robot-loader": "~2.4", "nette/security": "~2.4", - "latte/latte": "~2.4", + "latte/latte": "^2.4.1", "tracy/tracy": "^2.4" }, "conflict": { diff --git a/src/Bridges/ApplicationLatte/SnippetBridge.php b/src/Bridges/ApplicationLatte/SnippetBridge.php index 45f4b4406..86f5be6d0 100644 --- a/src/Bridges/ApplicationLatte/SnippetBridge.php +++ b/src/Bridges/ApplicationLatte/SnippetBridge.php @@ -39,6 +39,12 @@ public function isSnippetMode() } + public function setSnippetMode($snippetMode) + { + $this->control->snippetMode = $snippetMode; + } + + public function needsRedraw($name) { return $this->control->isControlInvalid($name); diff --git a/tests/Bridges.Latte/UIMacros.renderSnippets4.phpt b/tests/Bridges.Latte/UIMacros.renderSnippets4.phpt new file mode 100644 index 000000000..9388489d7 --- /dev/null +++ b/tests/Bridges.Latte/UIMacros.renderSnippets4.phpt @@ -0,0 +1,49 @@ +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);