From fe1e1d709a36886056398cb06c974a6f96a04e64 Mon Sep 17 00:00:00 2001 From: Oleg Kasyanov Date: Wed, 11 Dec 2019 03:53:49 +0400 Subject: [PATCH] Added sectionAppend() and sectionReplace() methods --- src/Template/Template.php | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/src/Template/Template.php b/src/Template/Template.php index ee7b57a..f9d1c89 100644 --- a/src/Template/Template.php +++ b/src/Template/Template.php @@ -137,6 +137,28 @@ public function layout(string $name, array $data = []): void $this->layoutData = $data; } + /** + * @param string $name + * @param string $content + */ + public function sectionReplace(string $name, string $content): void + { + $this->sections[$name] = $content; + } + + /** + * @param string $name + * @param string $content + */ + public function sectionAppend(string $name, string $content): void + { + if (! isset($this->sections[$name])) { + $this->sections[$name] = ''; + } + + $this->sections[$name] = $this->sections[$name] . $content; + } + /** * Start a new section block * @@ -193,7 +215,7 @@ public function stop(): void } /** - * Alias of stop() + * @deprecated */ public function end(): void { @@ -235,6 +257,7 @@ public function fetch(string $name, array $data = []): string * @param string $name * @param array $data * @throws Throwable + * @deprecated */ public function insert(string $name, array $data = []): void {