-
- Notifications
You must be signed in to change notification settings - Fork 112
Description
Version: 3.0.13
earlier versions probably too - related issue: #345
Bug Description
{$this->hasBlock('test')} yields different result than {hasBlock('test')}.
Relevant code:
latte/src/Latte/Essential/CoreExtension.php
Line 194 in 462444d
'hasBlock' => fn(string $name): bool => $this->template->hasBlock($name), latte/src/Latte/Runtime/Template.php
Lines 379 to 382 in 462444d
public function hasBlock(string $name): bool { return isset($this->blocks[self::LayerLocal][$name]) || isset($this->blocks[self::LayerTop][$name]); }
When using {$this->hasBlock()} the LayerTop array has many entries of Latte\Runtime\Block instances (key being the block's name), but it is empty when called using {hasBlock()}. In fact, the whole $this->blocks array only contains another empty arrays in this case.
Steps To Reproduce
default.latte (template of a presenter's action)
{block test}Test{/block}@layout.latte (main layout)
{$this->hasBlock('test')} {* true *} {hasBlock('test')} {* false *}Also, this in @layout.latte doesn't work:
{block test}test{/block} {dump $this->hasBlock('test')} {dump hasBlock('test')}Result:
Which is strange, because on fiddle it works:
I tried to make a failing example on fiddle.nette.org/latte, but I'm not able to simulate the relation between @layout.latte and a presenter/action template.
Expected Behavior
Both approaches have the same result.
Possible Solution
N/A
