-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Simplified the template code used to render flash messages
- Loading branch information
1 parent
a46c948
commit 7507a50
Showing
5 changed files
with
24 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,25 @@ | ||
{# | ||
Macros are comparable with functions in regular programming languages. | ||
They are useful to put often used HTML idioms into reusable elements to not repeat yourself. | ||
They are useful to put often used HTML idioms into reusable elements | ||
to not repeat yourself. | ||
See http://twig.sensiolabs.org/doc/tags/macro.html | ||
#} | ||
{% macro flashes(flash_keys, alert_class = 'info') %} | ||
{% from _self import alert %} | ||
{% for flash_key in flash_keys %} | ||
{% for flash_message in app.session.flashBag.get(flash_key) %} | ||
{{ alert(flash_message|trans, alert_class) }} | ||
{% macro render_flash_messages() %} | ||
{% from _self import alert %} | ||
|
||
<div class="messages"> | ||
{% for flash_message in app.session.flashBag.get('success') %} | ||
{{ alert(flash_message|trans) }} | ||
{% endfor %} | ||
{% endfor %} | ||
</div> | ||
{% endmacro %} | ||
|
||
{% macro alert(text, class = 'info') %} | ||
{% spaceless %} | ||
{# Bootstrap alert, see http://getbootstrap.com/components/#alerts #} | ||
<div class="alert alert-dismissible alert-{{ class }}" role="alert"> | ||
<button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">×</span></button> | ||
{{- text -}} | ||
</div> | ||
{% endspaceless %} | ||
{% macro alert(text, class = 'success') %} | ||
{# Bootstrap alert, see http://getbootstrap.com/components/#alerts #} | ||
<div class="alert alert-dismissible alert-{{ class }}" role="alert"> | ||
<button type="button" class="close" data-dismiss="alert" aria-label="Close"> | ||
<span aria-hidden="true">×</span> | ||
</button> | ||
{{ text }} | ||
</div> | ||
{% endmacro %} |
Binary file not shown.