diff --git a/src/Illuminate/View/Compilers/BladeCompiler.php b/src/Illuminate/View/Compilers/BladeCompiler.php index b6dd2abc0abe..d6ef4bb66105 100644 --- a/src/Illuminate/View/Compilers/BladeCompiler.php +++ b/src/Illuminate/View/Compilers/BladeCompiler.php @@ -186,17 +186,9 @@ public function setPath($path) */ public function compileString($value) { - if (strpos($value, '@verbatim') !== false) { - $value = $this->storeVerbatimBlocks($value); - } - - $this->footer = []; + [$this->footer, $result] = [[], '']; - if (strpos($value, '@php') !== false) { - $value = $this->storePhpBlocks($value); - } - - $result = ''; + $value = $this->storeUncompiledBlocks($value); // Here we will loop through all of the tokens returned by the Zend lexer and // parse each one into the corresponding valid PHP. We will then have this @@ -219,6 +211,25 @@ public function compileString($value) return $result; } + /** + * Store the blocks that do not receive compilation. + * + * @param string $value + * @return string + */ + protected function storeUncompiledBlocks($value) + { + if (strpos($value, '@verbatim') !== false) { + $value = $this->storeVerbatimBlocks($value); + } + + if (strpos($value, '@php') !== false) { + $value = $this->storePhpBlocks($value); + } + + return $value; + } + /** * Store the verbatim blocks and replace them with a temporary placeholder. *