diff --git a/src/Illuminate/View/Compilers/BladeCompiler.php b/src/Illuminate/View/Compilers/BladeCompiler.php index a7bb59e2bc51..7911462ebf32 100644 --- a/src/Illuminate/View/Compilers/BladeCompiler.php +++ b/src/Illuminate/View/Compilers/BladeCompiler.php @@ -390,8 +390,8 @@ protected function storeUncompiledBlocks($value) */ protected function storeVerbatimBlocks($value) { - return preg_replace_callback('/(?storeRawBlock($matches[1]); + return preg_replace_callback('/(?storeRawBlock($matches[2]); }, $value); } diff --git a/tests/View/Blade/BladeVerbatimTest.php b/tests/View/Blade/BladeVerbatimTest.php index dfe3eded7fb7..a6a2adc62910 100644 --- a/tests/View/Blade/BladeVerbatimTest.php +++ b/tests/View/Blade/BladeVerbatimTest.php @@ -86,4 +86,19 @@ public function testRawBlocksDontGetMixedUpWhenSomeAreRemovedByBladeComments() $this->assertSame($expected, $this->compiler->compileString($string)); } + + public function testNewlinesAreInsertedCorrectlyAfterEcho() + { + $string = "test @verbatim\nhello world\n@endverbatim"; + $expected = "test \nhello world\n"; + $this->assertSame($expected, $this->compiler->compileString($string)); + + $string = "{{ 1 }}\nhello world\n"; + $expected = "\n\nhello world\n"; + $this->assertSame($expected, $this->compiler->compileString($string)); + + $string = "{{ 1 }}@verbatim\nhello world\n@endverbatim"; + $expected = "\n\nhello world\n"; + $this->assertSame($expected, $this->compiler->compileString($string)); + } }