Skip to content

Commit 08887f9

Browse files
committed
refactor method
1 parent 2d09053 commit 08887f9

File tree

1 file changed

+21
-10
lines changed

1 file changed

+21
-10
lines changed

src/Illuminate/View/Compilers/BladeCompiler.php

+21-10
Original file line numberDiff line numberDiff line change
@@ -186,17 +186,9 @@ public function setPath($path)
186186
*/
187187
public function compileString($value)
188188
{
189-
if (strpos($value, '@verbatim') !== false) {
190-
$value = $this->storeVerbatimBlocks($value);
191-
}
192-
193-
$this->footer = [];
189+
[$this->footer, $result] = [[], ''];
194190

195-
if (strpos($value, '@php') !== false) {
196-
$value = $this->storePhpBlocks($value);
197-
}
198-
199-
$result = '';
191+
$value = $this->storeUncompiledBlocks($value);
200192

201193
// Here we will loop through all of the tokens returned by the Zend lexer and
202194
// parse each one into the corresponding valid PHP. We will then have this
@@ -219,6 +211,25 @@ public function compileString($value)
219211
return $result;
220212
}
221213

214+
/**
215+
* Store the blocks that do not receive compilation.
216+
*
217+
* @param string $value
218+
* @return string
219+
*/
220+
protected function storeUncompiledBlocks($value)
221+
{
222+
if (strpos($value, '@verbatim') !== false) {
223+
$value = $this->storeVerbatimBlocks($value);
224+
}
225+
226+
if (strpos($value, '@php') !== false) {
227+
$value = $this->storePhpBlocks($value);
228+
}
229+
230+
return $value;
231+
}
232+
222233
/**
223234
* Store the verbatim blocks and replace them with a temporary placeholder.
224235
*

0 commit comments

Comments
 (0)