From df0e6008eda575c491c13fe4b91624d593ed553c Mon Sep 17 00:00:00 2001 From: David Matejka Date: Wed, 25 May 2016 11:58:00 +0200 Subject: [PATCH] Control - snippets: prevent multiple rendering of nested snippets --- src/Application/UI/Control.php | 6 ++++-- tests/Bridges.Latte/UIMacros.renderSnippets.phpt | 1 + tests/Bridges.Latte/expected/UIMacros.renderSnippets.html | 1 + tests/Bridges.Latte/templates/snippet-include.latte | 4 ++++ 4 files changed, 10 insertions(+), 2 deletions(-) diff --git a/src/Application/UI/Control.php b/src/Application/UI/Control.php index b2f82e4e5..24f7dd890 100644 --- a/src/Application/UI/Control.php +++ b/src/Application/UI/Control.php @@ -112,7 +112,7 @@ public function redrawControl($snippet = NULL, $redraw = TRUE) $this->invalidSnippets = []; } else { - unset($this->invalidSnippets[$snippet]); + $this->invalidSnippets[$snippet] = FALSE; } } @@ -160,8 +160,10 @@ public function isControlInvalid($snippet = NULL) return FALSE; } + } elseif (isset($this->invalidSnippets[$snippet])) { + return $this->invalidSnippets[$snippet]; } else { - return isset($this->invalidSnippets["\0"]) || isset($this->invalidSnippets[$snippet]); + return isset($this->invalidSnippets["\0"]); } } diff --git a/tests/Bridges.Latte/UIMacros.renderSnippets.phpt b/tests/Bridges.Latte/UIMacros.renderSnippets.phpt index 70e84d357..5409931ff 100644 --- a/tests/Bridges.Latte/UIMacros.renderSnippets.phpt +++ b/tests/Bridges.Latte/UIMacros.renderSnippets.phpt @@ -62,6 +62,7 @@ Assert::same([ 'snippet--array2-3' => 'Value 3', 'snippet--includeSay' => 'Hello include snippet', 'snippet-multi-1-includeSay' => 'Hello', + 'snippet--nested1' => "\t
Foo
", ], ], (array) $presenter->payload); diff --git a/tests/Bridges.Latte/expected/UIMacros.renderSnippets.html b/tests/Bridges.Latte/expected/UIMacros.renderSnippets.html index 60c36e476..c0ebdcc56 100644 --- a/tests/Bridges.Latte/expected/UIMacros.renderSnippets.html +++ b/tests/Bridges.Latte/expected/UIMacros.renderSnippets.html @@ -11,3 +11,4 @@
Value 3
Hello include snippet
+
Foo
diff --git a/tests/Bridges.Latte/templates/snippet-include.latte b/tests/Bridges.Latte/templates/snippet-include.latte index e78e3d487..b59d67c45 100644 --- a/tests/Bridges.Latte/templates/snippet-include.latte +++ b/tests/Bridges.Latte/templates/snippet-include.latte @@ -19,3 +19,7 @@ {snippetArea} {include snippet-included.latte say => 'Hello include snippet'} {/snippetArea} + +{snippet nested1} + {snippet nested2}Foo{/snippet} +{/snippet}