The Twig manual (“include“) says this:
{% include 'foo' with {'foo': 'bar'} %}
But this works fine too:
{% include 'foo' with { foo: 'bar'} %}
So is there any difference or are the quotes arbitrary?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
The previous answer by @Maerlyn is not completely accurate.
As of Twig 1.5 you can use unquoted strings as the key name in hashes. For example
{foo: 'bar'}is the same as{'foo': 'bar'}even if you had a variable namedfooin your template it would not clash with the hash key name offoo. It’s a convenience thing, that’s all.For example:
Expected output: