Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/Html/BlockBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ public function append(string $name, string $content): void
*
* If the block does not exist, then the `$default` content will be returned instead.
*/
public function placeholder(string $name, string $default = ''): string
public function placeholder(string $name, string $default = null): ?string
{
$result = $this->get($name, $default);
unset($this->blocks[$name]);
Expand All @@ -120,7 +120,7 @@ public function placeholder(string $name, string $default = ''): string
*
* If the block does not exist, then the `$default` content will be returned instead.
*/
public function get(string $name, string $default = ''): string
public function get(string $name, string $default = null): ?string
{
if (!isset($this->blocks[$name])) {
return $default;
Expand Down
9 changes: 9 additions & 0 deletions tests/Html/BlockBuilderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -229,4 +229,13 @@ public function testContainBetweenBlocks()
);
$this->assertEquals('In between', $content);
}

public function testGetBlock()
{
$result = $this->Block->get('non-existent-block');
$this->assertNull($result);

$result = $this->Block->get('non-existent-block', 'default value');
$this->assertEquals('default value', $result);
}
}