Reputation: 45
Im trying to access to app.user.username on my twig template.
Running Symfony3.4.
My auth is working so that should not be the problem.
This is the code:
{% extends "@Foro/layout.html.twig" %}
{% block content %}
{% if is_granted('ROLE_USER') %}
<strong>You're a normal user</strong>
{% endif %}
{% if is_granted('ROLE_ADMIN') %}
{% app.user.username %}
<strong>You're an admin</strong>
{% endif %}
<div class="col-lg-4">
<h2>Identifícate</h2>
<hr/>
<form action="{{ path("login_check") }}" method="POST">
<label>Email:</label>
<input type="email" id="username" name="_username" class="form-control" />
<label>Contraseña:</label>
<input type="password" id="password" name="_password" class="form-control" />
<br/>
<input type="submit" value="Entrar" class="btn btn-success" />
<input type="hidden" name="_target_path" value="/login" />
</form>
</div>
<div class="clearfix"></div>
{% endblock %}
I get the following error:
Unexpected "app" tag (expecting closing tag for the "if" tag defined near line 8).
Can you guys help me out?
Upvotes: 1
Views: 577