diff --git a/src/Gin/Template/Template.php b/src/Gin/Template/Template.php index ad91bb6..c87f261 100644 --- a/src/Gin/Template/Template.php +++ b/src/Gin/Template/Template.php @@ -139,9 +139,13 @@ public function isNamed() return false; } - // Return false if template is named, - // but name is bool or null. - if (isset($this->file[1]) && is_bool($this->file[1]) || null === $this->file[1]) { + // Return false if template is named, but name + // is invalid. A valid name should be: + if ( + isset($this->file[1]) && is_bool($this->file[1]) // should be set and not be a boolean + || null === $this->file[1] // or null value + || empty($this->file[1]) // or empty sting or array + ) { return false; } diff --git a/tests/Gin/Template/TemplateTest.php b/tests/Gin/Template/TemplateTest.php index e728db1..93193dd 100644 --- a/tests/Gin/Template/TemplateTest.php +++ b/tests/Gin/Template/TemplateTest.php @@ -108,6 +108,10 @@ public function it_should_return_no_named_filename_when_template_name_is_not_val $invalidNamedTemplate = $this->getTemplate($config, ['sample_template', null]); $this->assertFalse($invalidNamedTemplate->isNamed()); $this->assertEquals('sample_template.php', $invalidNamedTemplate->getFilename()); + + $invalidNamedTemplate = $this->getTemplate($config, ['sample_template', '']); + $this->assertFalse($invalidNamedTemplate->isNamed()); + $this->assertEquals('sample_template.php', $invalidNamedTemplate->getFilename()); } /**