-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
pass by value in block node #44
Comments
I think this is a bad idea, but can you give me a concrete example for that? |
OK. Let we have index.phtml and index-overriden.phtml. index.phtml: Hello {{ name }} index-overriden.phtml: {% extends "index/index.phtml" %} if you open in browser index.phtml you will see only "Hello" word and in index-overriden.phtml you will see same result. If change wig/lib/Twig/Node/Block.php as i show above; Then content of index.phtml will be "Hello John" and content of index-overriden.phtml will be "Hello Overriden John ". You can said that use some think like this in index.phtml: Hello but when we have big template with not trivial or many overriden parts more easy override variables then put block in each place. Or for example when override one variable and then use in several places. I think this is useful ability. If this bad idea can you said why, becouse i use this modification in my project. |
Blocks are to be seen as methods. They are isolated. So, this is the expected behavoir. And I still don't see a real-world usage. The set tag is rarely useful in a template. |
I think that in
Twig/lib/Twig/Node/Block.php lib/Twig/Node/Block.php on line 68
instead :
->write(sprintf("public function block_%s($context)\n", $this->name), "{\n")
must be:
->write(sprintf("public function block_%s(&$context)\n", $this->name), "{\n")
This need in case when need set value to context in child template and then parent read that value.
The text was updated successfully, but these errors were encountered: