Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

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.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8923097
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T07:01:35+00:00 2026-06-15T07:01:35+00:00

The Twig manual ( include ) says this: {% include ‘foo’ with {‘foo’: ‘bar’}

  • 0

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?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T07:01:37+00:00Added an answer on June 15, 2026 at 7:01 am

    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 named foo in your template it would not clash with the hash key name of foo. It’s a convenience thing, that’s all.

    For example:

    {% set foo = 'bar' %}
    {% set bar = {foo: foo} %} {# note: no quotes around foo #}
    {% debug bar %}
    

    Expected output:

    array
      'foo' => string 'bar' (length=3)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to optimize my source code Twig but this does not look very
Are there any filters or something like that in twig template engine to format
I'm trying to use translation in a custom twig filter like this public function
I have a base Twig template that has a search bar form in it
In Symfony2 TWIG, when trying to generate a path like this: <a href={{ path('folder_new',
I am currently writing some extensions in twig, but I am having trouble deciding
I have been looking at this twig code for a while, and tried a
I have a html.twig file with this {% set num= 1%} {% for idea
There are two twig files src/MyVendor/MyBundle/Resources/views/MyApp/layout.html.twig and src/MyVendor/MyBundle/Resources/views/MyApp/myView.html.twig . The content of src/MyVendor/MyBundle/Resources/views/MyApp/myView.html.twig {%
I'm new to Twig and like it, but i've got one problem right now.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.