- Block can now reference a 'this' object from it's {% using [ 'this' => new stdClass() ] %} token
- Fixed a bug with {% use %} which was buggy whenever two uses were declared and one of them had a curly braces notation in it.
This commit is contained in:
parent
7970679894
commit
35a7bd4cf7
|
@ -21,7 +21,7 @@ class Builder
|
|||
|
||||
$replace = [
|
||||
'%NAMESPACE%' => $context->namespace,
|
||||
'%USE%' => ( $uses = $context->renderUses() ) ? "use $uses;" : false,
|
||||
'%USE%' => ( $uses = $context->renderUses() ) ? $uses : false,
|
||||
'%CLASSNAME%' => $context->className,
|
||||
'%PATHNAME%' => $path($context->viewPath),
|
||||
'%FULLPATH%' => $path($context->filePath),
|
||||
|
|
|
@ -57,7 +57,7 @@ abstract class Context {
|
|||
|
||||
public function renderUses() : string
|
||||
{
|
||||
return implode(",", $this->useStack ?? []);
|
||||
return implode(PHP_EOL, array_map(fn($use) => "use $use;", $this->useStack ?? []));
|
||||
}
|
||||
|
||||
public function renderFunctions() : string
|
||||
|
|
|
@ -227,7 +227,12 @@ class BlockToken implements ControlStructure {
|
|||
{
|
||||
$this->rendering = true;
|
||||
|
||||
return $classTemplate->picea->inlineBlock($this, $this->viewPath, ...$this->arguments);
|
||||
if ($this->using['this'] ?? false) {
|
||||
$thisProxy = $this->using['this'];
|
||||
unset($this->using['this']);
|
||||
}
|
||||
|
||||
return $classTemplate->picea->inlineBlock($thisProxy ?? $this, $this->viewPath, ...$this->arguments);
|
||||
}
|
||||
|
||||
public function setSlot(string $name, Callable $method) : void
|
||||
|
|
Loading…
Reference in New Issue