Skip to content

Commit 02565d1

Browse files
authored
Merge pull request #2515 from najdanovicivan/layout-renderer-fix
Layout Renderer Fix
2 parents add2f5f + e32785e commit 02565d1

2 files changed

Lines changed: 14 additions & 1 deletion

File tree

system/View/View.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -480,9 +480,10 @@ public function renderSection(string $sectionName)
480480
return;
481481
}
482482

483-
foreach ($this->sections[$sectionName] as $contents)
483+
foreach ($this->sections[$sectionName] as $key => $contents)
484484
{
485485
echo $contents;
486+
unset($this->sections[$sectionName][$key]);
486487
}
487488
}
488489

tests/system/View/ViewTest.php

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -276,6 +276,18 @@ public function testRenderLayoutExtendsCorrectly()
276276
$this->assertContains($expected, $view->render('extend'));
277277
}
278278

279+
public function testRenderLayoutExtendsMultipleCalls()
280+
{
281+
$view = new View($this->config, $this->viewsDir, $this->loader);
282+
283+
$view->setVar('testString', 'Hello World');
284+
$expected = "<p>Open</p>\n<h1>Hello World</h1>\n<p>Hello World</p>";
285+
286+
$view->render('extend');
287+
288+
$this->assertContains($expected, $view->render('extend'));
289+
}
290+
279291
public function testRenderLayoutMakesDataAvailableToBoth()
280292
{
281293
$view = new View($this->config, $this->viewsDir, $this->loader);

0 commit comments

Comments
 (0)