Skip to content

Commit

Permalink
Merge pull request #2515 from najdanovicivan/layout-renderer-fix
Browse files Browse the repository at this point in the history
Layout Renderer Fix
  • Loading branch information
lonnieezell authored Jan 30, 2020
2 parents add2f5f + e32785e commit 02565d1
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
3 changes: 2 additions & 1 deletion system/View/View.php
Original file line number Diff line number Diff line change
Expand Up @@ -480,9 +480,10 @@ public function renderSection(string $sectionName)
return;
}

foreach ($this->sections[$sectionName] as $contents)
foreach ($this->sections[$sectionName] as $key => $contents)
{
echo $contents;
unset($this->sections[$sectionName][$key]);
}
}

Expand Down
12 changes: 12 additions & 0 deletions tests/system/View/ViewTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -276,6 +276,18 @@ public function testRenderLayoutExtendsCorrectly()
$this->assertContains($expected, $view->render('extend'));
}

public function testRenderLayoutExtendsMultipleCalls()
{
$view = new View($this->config, $this->viewsDir, $this->loader);

$view->setVar('testString', 'Hello World');
$expected = "<p>Open</p>\n<h1>Hello World</h1>\n<p>Hello World</p>";

$view->render('extend');

$this->assertContains($expected, $view->render('extend'));
}

public function testRenderLayoutMakesDataAvailableToBoth()
{
$view = new View($this->config, $this->viewsDir, $this->loader);
Expand Down

0 comments on commit 02565d1

Please sign in to comment.