symfony - How to use if else for a controller variable on twig -
what im trying compare imageowner (variable returned controller) current user
<!-- image remove button --> {% if {{ imageowner }} == {{ app.user.username }} %} //line 5 <p>you owner of image</p> <button onclick="deletestuff()">deleted</button> {% endif %}
but throws error
a hash key must quoted string, number, name, or expression enclosed in parentheses (unexpected token "punctuation" of value "{" inlayoutbundle:frontpage:content-bubble.html.twig @ line 5
the {{ imageowner }} , {{ app.user.username }} return right values, think syntax or logical error
use
{% if imageowner == app.user.username %} //line 5 <p>you owner of image</p> <button onclick="deletestuff()">deleted</button> {% endif %}
{{ imageowner }}
slimier echo $imageowner
in php. not need wrap variable {{}}
when don't want print it.
Comments
Post a Comment