Skip to content

Commit

Permalink
[WIP] Fix render only one fragment
Browse files Browse the repository at this point in the history
  • Loading branch information
neznaika0 committed Oct 5, 2024
1 parent cdae0e9 commit 10e9d30
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/View/View.php
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,8 @@ public function render(string $view, ?array $options = null, ?bool $saveData = n
} elseif (! empty($this->renderVars['options']['fragments']) && $this->fragmentStack === []) {
$output = '';

$this->fragments = array_intersect_key($this->fragments, array_flip($this->renderVars['options']['fragments']));

foreach ($this->renderVars['options']['fragments'] as $fragmentName) {
$output .= $this->renderFragment($fragmentName);
unset($this->fragments[$fragmentName]);
Expand Down Expand Up @@ -197,9 +199,13 @@ protected function renderFragment(string $fragmentName)
return '';
}

$output = '';

foreach ($this->fragments[$fragmentName] as $contents) {
return $contents;
$output .= $contents;
}

return $output;
}

/**
Expand Down

0 comments on commit 10e9d30

Please sign in to comment.