Skip to content

Commit

Permalink
refactor method
Browse files Browse the repository at this point in the history
  • Loading branch information
taylorotwell committed Jan 2, 2020
1 parent 2d09053 commit 08887f9
Showing 1 changed file with 21 additions and 10 deletions.
31 changes: 21 additions & 10 deletions src/Illuminate/View/Compilers/BladeCompiler.php
Expand Up @@ -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
Expand All @@ -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.
*
Expand Down

0 comments on commit 08887f9

Please sign in to comment.