diff --git a/src/Latte/Runtime/ISnippetBridge.php b/src/Latte/Runtime/ISnippetBridge.php index 4ed2e8892..2be52ea75 100644 --- a/src/Latte/Runtime/ISnippetBridge.php +++ b/src/Latte/Runtime/ISnippetBridge.php @@ -21,6 +21,13 @@ interface ISnippetBridge function isSnippetMode(); + /** + * @param bool + * @return void + */ + function setSnippetMode($snippetMode); + + /** * @param string * @return bool diff --git a/src/Latte/Runtime/SnippetDriver.php b/src/Latte/Runtime/SnippetDriver.php index 2c312fb66..c443c6b11 100644 --- a/src/Latte/Runtime/SnippetDriver.php +++ b/src/Latte/Runtime/SnippetDriver.php @@ -43,7 +43,7 @@ public function __construct(ISnippetBridge $bridge) public function enter($name, $type) { - if (!$this->bridge->isSnippetMode()) { + if (!$this->renderingSnippets) { return; } $obStarted = FALSE; @@ -63,7 +63,7 @@ public function enter($name, $type) public function leave() { - if (!$this->bridge->isSnippetMode()) { + if (!$this->renderingSnippets) { return; } list($name, $obStarted) = array_pop($this->stack); @@ -88,6 +88,7 @@ public function renderSnippets(array $blocks, array $params) return FALSE; } $this->renderingSnippets = TRUE; + $this->bridge->setSnippetMode(FALSE); foreach ($blocks as $name => $function) { if ($name[0] !== '_' || !$this->bridge->needsRedraw(substr($name, 1))) { continue; @@ -95,6 +96,7 @@ public function renderSnippets(array $blocks, array $params) $function = reset($function); $function($params); } + $this->bridge->setSnippetMode(TRUE); $this->bridge->renderChildren(); return TRUE; } diff --git a/tests/Latte/mocks/SnippetBridge.php b/tests/Latte/mocks/SnippetBridge.php index 7f70f5f6f..53f24bd23 100644 --- a/tests/Latte/mocks/SnippetBridge.php +++ b/tests/Latte/mocks/SnippetBridge.php @@ -17,6 +17,12 @@ public function isSnippetMode() } + public function setSnippetMode($snippetMode) + { + $this->snippetMode = $snippetMode; + } + + public function needsRedraw($name) { return $this->invalid === TRUE || isset($this->invalid[$name]);