diff --git a/src/Illuminate/View/Compilers/BladeCompiler.php b/src/Illuminate/View/Compilers/BladeCompiler.php index 08bb14b7fb31..0f084b06ffec 100644 --- a/src/Illuminate/View/Compilers/BladeCompiler.php +++ b/src/Illuminate/View/Compilers/BladeCompiler.php @@ -118,10 +118,17 @@ public function compile($path = null) } if (! is_null($this->cachePath)) { - $contents = $this->compileString($this->files->get($this->getPath())). - "\ngetPath()} */ ?>"; + $contents = $this->compileString( + $this->files->get($this->getPath()) + ); - $this->files->put($this->getCompiledPath($this->getPath()), $contents); + if (! empty($this->getPath())) { + $contents .= "\ngetPath()} */ ?>"; + } + + $this->files->put( + $this->getCompiledPath($this->getPath()), $contents + ); } } diff --git a/tests/View/ViewBladeCompilerTest.php b/tests/View/ViewBladeCompilerTest.php index 9e32b7d21400..67720dcc5cf1 100644 --- a/tests/View/ViewBladeCompilerTest.php +++ b/tests/View/ViewBladeCompilerTest.php @@ -101,6 +101,24 @@ public function testIncludePathToTemplate() $compiler->compile('foo'); } + public function testDontIncludeEmptyPath() + { + $compiler = new BladeCompiler($files = $this->getFiles(), __DIR__); + $files->shouldReceive('get')->once()->with('')->andReturn('Hello World'); + $files->shouldReceive('put')->once()->with(__DIR__.'/'.sha1('').'.php', 'Hello World'); + $compiler->setPath(''); + $compiler->compile(); + } + + public function testDontIncludeNullPath() + { + $compiler = new BladeCompiler($files = $this->getFiles(), __DIR__); + $files->shouldReceive('get')->once()->with(null)->andReturn('Hello World'); + $files->shouldReceive('put')->once()->with(__DIR__.'/'.sha1(null).'.php', 'Hello World'); + $compiler->setPath(null); + $compiler->compile(); + } + public function testShouldStartFromStrictTypesDeclaration() { $compiler = new BladeCompiler($files = $this->getFiles(), __DIR__);