Are global variables part of the context or not? #3971
-
According to this documentation, it is possible to declare global variables to the PHP compiler: https://twig.symfony.com/doc/3.x/advanced.html#globals
It is not clear though if these variables are part of the context or not. Specifically if they are part of the context, they must not be passed to included templates when
But if they are not part of the context, then they must not be part of the content of the
Can someone please clarify this point? Note also the confusing naming by the way between global variables passed by executing What is the nuance between the two concepts of global variables? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 5 replies
-
They are added in the context for each template. So even when you don |
Beta Was this translation helpful? Give feedback.
They are added in the context for each template. So even when you don
with_context=false
, they are still there (they are not forwarded from the caller by the include function, but they are still inserted in the context by the Environment as they are global variables)