I'm working in Symfony and tried to pass a variable called $services
into my twig template. Naturally, I would also refer to the variable in twig with the same name.
$services = new ArrayCollection(); // Some array
$this->render('template.html.twig', [
'services' => $services
]);
For some reason however, services
always is a boolean value of true
. This is instead of the ArrayCollection
I am trying to pass into it.
I've checked my twig configuration for anything that could be assigning itself as a global variable but everything checks out, and I can't seem to find any documentation about services
being a reserved keyword.
FWIW, I renamed the twig variable name from services
to foo
for sanity checking and the $services
variable behaves as expected, so it's definitely got something to do with assigning a variable to the word services
in twig.
I'm currently running Twig 2.14.3
Apart from checking if there are any global variables set, are there any other avenues for trying to find why and where this variable would be defined?
question from:
https://stackoverflow.com/questions/65868577/twig-keyword-services-always-has-the-value-true 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…