Skip to content
This repository has been archived by the owner on Nov 14, 2024. It is now read-only.

Commit

Permalink
Merge branch 'master' into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
jedrzejchalubek committed Mar 21, 2018
2 parents 4509934 + 1e726ec commit 2081ddc
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
10 changes: 7 additions & 3 deletions src/Gin/Template/Template.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down
4 changes: 4 additions & 0 deletions tests/Gin/Template/TemplateTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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());
}

/**
Expand Down

0 comments on commit 2081ddc

Please sign in to comment.