forked from symfony/demo
-
Notifications
You must be signed in to change notification settings - Fork 24
/
Copy path_flash_messages.html.twig
32 lines (28 loc) · 1.36 KB
/
_flash_messages.html.twig
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
{#
This is a template fragment designed to be included in other templates
See https://symfony.com/doc/current/book/templating.html#including-other-templates
A common practice to better distinguish between templates and fragments is to
prefix fragments with an underscore. That's why this template is called
'_flash_messages.html.twig' instead of 'flash_messages.html.twig'
#}
{#
The request method check is needed to prevent starting the session when looking for "flash messages":
https://symfony.com/doc/current/session/avoid_session_start.html
TIP: With FOSHttpCache you can also adapt this to make it cache safe:
https://foshttpcachebundle.readthedocs.io/en/latest/features/helpers/flash-message.html
#}
{% if app.request.hasPreviousSession %}
<div class="messages">
{% for type, messages in app.flashes %}
{% for message in messages %}
{# Bootstrap alert, see http://getbootstrap.com/components/#alerts #}
<div class="alert alert-dismissible alert-{{ type }} fade in" role="alert">
<button type="button" class="close" data-dismiss="alert" aria-label="Close">
<span aria-hidden="true">×</span>
</button>
{{ message|trans }}
</div>
{% endfor %}
{% endfor %}
</div>
{% endif %}