Skip to content

Commit a3bfc27

Browse files
committed
Merge branch 'piotr-cz/bugfix/fetch-infinite-loop'
Closes #53
2 parents a13ada9 + a7ee036 commit a3bfc27

1 file changed

Lines changed: 4 additions & 3 deletions

File tree

src/PhpRenderer.php

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ public function __construct($templatePath = "", $attributes = [], $layout = "")
6666
*/
6767
public function render(ResponseInterface $response, $template, array $data = [])
6868
{
69-
$output = $this->fetch($template, $data);
69+
$output = $this->fetch($template, $data, true);
7070

7171
$response->getBody()->write($output);
7272

@@ -174,13 +174,14 @@ public function setTemplatePath($templatePath)
174174
*
175175
* @param $template
176176
* @param array $data
177+
* @param bool $useLayout
177178
*
178179
* @return mixed
179180
*
180181
* @throws \InvalidArgumentException
181182
* @throws \RuntimeException
182183
*/
183-
public function fetch($template, array $data = []) {
184+
public function fetch($template, array $data = [], $useLayout = false) {
184185
if (isset($data['template'])) {
185186
throw new \InvalidArgumentException("Duplicate template key found");
186187
}
@@ -204,7 +205,7 @@ public function fetch($template, array $data = []) {
204205
$this->protectedIncludeScope($this->templatePath . $template, $data);
205206
$output = ob_get_clean();
206207

207-
if ($this->layout !== null) {
208+
if ($this->layout !== null && $useLayout) {
208209
ob_start();
209210
$data['content'] = $output;
210211
$this->protectedIncludeScope($this->layout, $data);

0 commit comments

Comments
 (0)