{$this->hasBlock('test')} yields different result than {hasBlock('test')}
Closed this issue · 1 comments
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
latte/src/Latte/Runtime/Template.php
Lines 379 to 382 in 462444d
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
Thanks, it is working now 👍
Note for anyone updating - if you see this error, don't panic 🙂
The solution is easy - clear latte cache.
TypeError
Latte\Essential\CoreExtension::Latte\Essential\{closure}(): Argument #1 ($template) must be of type Latte\Runtime\Template, string given, called in /{path_to_project}/temp/cache/latte/Front-templates-@layout.latte--c33d85f130.php on line 321