Skip to content
Snippets Groups Projects
Unverified Commit 93693762 authored by Thomas Flori's avatar Thomas Flori
Browse files

add provide method to provide a section without output buffering

parent 60561704
No related branches found
No related tags found
No related merge requests found
......@@ -117,17 +117,22 @@ class View
throw new \LogicException('You must start a section before you can end it.');
}
$content = trim(ob_get_clean());
if ($this->appendSection && isset($this->sections[$this->sectionName])) {
$this->sections[$this->sectionName] .= $content;
} else {
$this->sections[$this->sectionName] = $content;
}
$this->provide($this->sectionName, ob_get_clean(), $this->appendSection);
$this->sectionName = null;
$this->appendSection = false;
}
public function provide(string $name, string $content, bool $append = false)
{
$content = trim($content, "\t\n\r\0\x0b");
if ($append && isset($this->sections[$name])) {
$this->sections[$name] .= $content;
} else {
$this->sections[$name] = $content;
}
}
public function section(string $name, string $default = null): string
{
if (!isset($this->sections[$name])) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment