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

  • Home
  • SEARCH
  • 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 8208279
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T09:17:10+00:00 2026-06-07T09:17:10+00:00

As per title, does Twig allow assignments in conditional and how? I know that

  • 0

As per title, does Twig allow assignments in conditional and how? I know that not all people like these assignments but sometimes they can be very helpful.

This:

{% if (name = attribute(mappings, property)) is defined %}
    {% else %}
    {% set attrs = attrs|merge(['%s="%s"'|format(name, value)]) %}
{% endif %}

…is not working and gives me and error:

An opened parenthesis is not properly closed. Unexpected token
“operator” of value “=” (“punctuation” expected with value “)”) in
::tooltips.html.twig at line 29.

  • 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-07T09:17:12+00:00Added an answer on June 7, 2026 at 9:17 am

    Your twig error is because of this line

    {% if (name = attribute(mappings, property)) is defined %}
    

    Twig doesn’t like assignment-in-condition expressions, and personally neither do I, it’s just a lazy shortcut and the potential issues isn’t worth saving a few keystrokes.

    But I have to now admit that I’m confused by what this is supposed to do. You’re attempting to capture the result of attribute(mappings, property) into name but if that fails, only then do you do something using name, but by then name won’t have a value unless it’s been defined elsewhere in the template.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

As per title. I have a piece of jQuery that looks like the following
as per title above, when I trigger the controller with a hyperlink, it does
As per the title, it seems only Chrome isn't playign along. Note that form
I would like to write a C# method that would transform any title into
I know C/C++/C#/ActionScript/PHP and have worked in all of them. As per my Knowledge
As per the title, if we used to call cursor.requery() , but it is
As per title i am trying to measure page performance in IE6 that has
I have set up a title instance variable in application_helper.rb, but the base_title does
As per title, can an ActorContext extracted from within an actor be safely used
As per title, what practise for string comparisons do you use and why?

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.