user1855861
user1855861

Reputation: 41

if variable twig on symfony

I would like to do a test on the values ​​selected by the select tag multiple. I tried with this code, but I get this error:

A hash key must be a quoted string, a number, a name, or an expression enclosed in parentheses (unexpected token "punctuation" of value "{" in AdminBlogBundle:GestionGraph:graphkpi1.html.twig at line 575

{% for liste in Col1_Array %}
    {% if {{liste}} is "Call Drop" %}
     <div id="chartdiv" style="width: 100%; height: 400px;"></div>
    {% else %}
      <div id="chartdiv1" style="width: 100%; height: 400px;"></div>
    {% endif %}
{% endfor %}

Who can help me please?

Upvotes: 4

Views: 20130

Answers (3)

Try

{{ dump(liste) }}

to find out what really is being evaluated.

Upvotes: 0

Pete Thompson
Pete Thompson

Reputation: 131

Fairly sure your line:

{% if {{liste}} is "Call Drop" %}

Should be:

{% if liste is "Call Drop" %}

Upvotes: 5

Clarence
Clarence

Reputation: 2964

You can't nest delimeters like that.

Correct syntax would be:

{% if liste == "Call Drop" %}

Upvotes: 10

Related Questions