- A lot of bugfixes made for this release.
This commit is contained in:
1 parent
4e909b2840
commit
8df38b568c
13 files changed
+159
-71
No files matched your search
@@ -20,6 +20,10 @@ if (! class_exists("%NAMESPACE%\%CLASSNAME%", false) ) {
|
||||
|
||||
public static $context;
|
||||
|
||||
public bool $rendering = false;
|
||||
|
||||
public bool $renderingInsideSection = false;
|
||||
|
||||
public function __construct(\Picea\Picea $picea, array $variablesList = [], ?object $thisProxy = null) {
|
||||
$this->picea = $picea;
|
||||
$this->variableList = $variablesList;
|
||||
@@ -33,32 +37,49 @@ if (! class_exists("%NAMESPACE%\%CLASSNAME%", false) ) {
|
||||
|
||||
public function output(array $variablesList = []) : void
|
||||
{
|
||||
$this->rendering = true;
|
||||
|
||||
( function($___class__template, $___global_variables, $___variables, $picea) {
|
||||
extract($___global_variables);
|
||||
extract($___variables, \EXTR_OVERWRITE);
|
||||
?>%CONTENT%<?php
|
||||
} )->call($this->thisProxy ?? new class(){}, $this, $this->variableList, $variablesList, $this->picea);
|
||||
%PARENT_OUTPUT%
|
||||
|
||||
$this->rendering = false;
|
||||
}
|
||||
|
||||
public function renderSection($name) : void
|
||||
public function renderSection(string $name, bool $return = false) /*: string|void*/
|
||||
{
|
||||
$result = [];
|
||||
|
||||
foreach([ 'prepend', 'default', 'append' ] as $item) {
|
||||
if ( ! is_array($this->sectionList[$name][$item]) ) continue;
|
||||
|
||||
usort($this->sectionList[$name][$item], fn($a, $b) => $a['order'] <=> $b['order']);
|
||||
|
||||
foreach($this->sectionList[$name][$item] as $section) {
|
||||
if ($return) {
|
||||
ob_start();
|
||||
}
|
||||
|
||||
$section['callback']();
|
||||
|
||||
if ($return) {
|
||||
$result[] = ob_get_clean();
|
||||
}
|
||||
|
||||
if ( $item === 'default' ) {
|
||||
break 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $return ? implode("", $result) : "";
|
||||
}
|
||||
|
||||
public function exportFunctions() : void
|
||||
{
|
||||
static $caching = [];
|
||||
%FUNCTIONS%
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user