Skip to content

Commit

Permalink
Added sectionAppend() and sectionReplace() methods
Browse files Browse the repository at this point in the history
  • Loading branch information
batumibiz committed Dec 10, 2019
1 parent 84fae95 commit fe1e1d7
Showing 1 changed file with 24 additions and 1 deletion.
25 changes: 24 additions & 1 deletion src/Template/Template.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
*
Expand Down Expand Up @@ -193,7 +215,7 @@ public function stop(): void
}

/**
* Alias of stop()
* @deprecated
*/
public function end(): void
{
Expand Down Expand Up @@ -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
{
Expand Down

0 comments on commit fe1e1d7

Please sign in to comment.