Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

{$this->hasBlock('test')} yields different result than {hasBlock('test')} #357

Closed
Gappa opened this issue Feb 7, 2024 · 1 comment
Closed

Comments

@Gappa
Copy link

Gappa commented Feb 7, 2024

Version: 3.0.13
earlier versions probably too - related issue: #345

Bug Description

{$this->hasBlock('test')} yields different result than {hasBlock('test')}.

Relevant code:

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:

image

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

@Gappa Gappa changed the title {$this->hasBlock('test)} yields different result than {hasBlock('test')} {$this->hasBlock('test')} yields different result than {hasBlock('test')} Feb 7, 2024
@dg dg closed this as completed in bac98d0 Mar 19, 2024
@Gappa
Copy link
Author

Gappa commented Mar 19, 2024

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/[email protected] on line 321

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant