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

Twig_Template::hasBlock does not regard extended templates #450

Closed
OvalMedia opened this issue Sep 25, 2011 · 2 comments
Closed

Twig_Template::hasBlock does not regard extended templates #450

OvalMedia opened this issue Sep 25, 2011 · 2 comments

Comments

@OvalMedia
Copy link

A template's $blocks array does not contain any parent's blocks. So when extending a template hasBlock returns false when the block in question does not exist in the child template. The rendering itself works fine since the block does exist in the parent's template.

So basically the hasBlock function is lacking consequence. There is no way to check if a block exists before rendering a template that extends others.

@fabpot
Copy link
Contributor

fabpot commented Sep 27, 2011

hasBlock as all other methods in Twig_Template are for internal use only. You should not use them. hasBlock cannot return blocks for the parent as the parent template can be a dynamic value, which is only known based on the current context.

@fabpot fabpot closed this as completed Sep 27, 2011
@fabpot
Copy link
Contributor

fabpot commented Sep 27, 2011

I've just added some information about this in the phpdoc (d9d38d6) to avoid confusion.

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

No branches or pull requests

2 participants