Reputation: 1539
What im trying to do is compare the imageowner (variable returned by the controller) with the current user
<!-- image remove button -->
{% if {{ imageOwner }} == {{ app.user.username }} %} //Line 5
<p>You are the owner of this image</p>
<button onclick="deleteStuff()">deleted</button>
{% endif %}
but it throws 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 "{" inLayoutBundle:Frontpage:content-bubble.html.twig at line 5
the {{ imageOwner }} and {{ app.user.username }} return the right values, I think its a syntax or logical error
Upvotes: 0
Views: 769
Reputation: 3394
Use
{% if imageOwner == app.user.username %} //Line 5
<p>You are the owner of this image</p>
<button onclick="deleteStuff()">deleted</button>
{% endif %}
{{ imageOwner }}
is slimier to echo $imageOwner
in php. So you do not need to wrap variable with {{}}
when you don't want to print it.
Upvotes: 3