Skip to content

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

@Gappa

Description

@Gappa

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions