Skip to content

Commit

Permalink
Compile Blade comments first in order to prevent Blade from compiling…
Browse files Browse the repository at this point in the history
… statements inside comments (#17952)
  • Loading branch information
sileence authored and taylorotwell committed Feb 16, 2017
1 parent 6f13147 commit b7f2c69
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/Illuminate/View/Compilers/BladeCompiler.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,9 @@ class BladeCompiler extends Compiler implements CompilerInterface
* @var array
*/
protected $compilers = [
'Comments',
'Extensions',
'Statements',
'Comments',
'Echos',
];

Expand Down
8 changes: 8 additions & 0 deletions tests/View/Blade/BladeCommentsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,14 @@ public function testCommentsAreCompiled()
$this->assertEmpty($compiler->compileString($string));
}

public function testBladeCodeInsideCommentsIsNotCompiled()
{
$compiler = new BladeCompiler($this->getFiles(), __DIR__);
$string = '{{-- @foreach() --}}';

$this->assertEmpty($compiler->compileString($string));
}

protected function getFiles()
{
return m::mock('Illuminate\Filesystem\Filesystem');
Expand Down

0 comments on commit b7f2c69

Please sign in to comment.