{% set all_messages = get_flashed_messages(with_categories=true) %} {% set toasts = [] %} {% for cat, msg in all_messages if cat.startswith('toast-') %} {% set _ = toasts.append((cat, msg)) %} {% endfor %} {% if toasts %} {% endif %}