{# Normalise: accept a single dict, a list of dicts, or nothing #} {% if theme_announcement_banner %} {% if theme_announcement_banner is mapping %} {% set ast_items = [theme_announcement_banner] %} {% else %} {% set ast_items = theme_announcement_banner %} {% endif %} {% else %} {% set ast_items = [] %} {% endif %} {# Compute most-severe type for the banner border/icon #} {% set _priority = {'error': 3, 'warning': 2, 'success': 1, 'info': 0} %} {% set ns = namespace(banner_type='info') %} {% for item in ast_items %} {% if _priority.get(item.get('type','info'), 0) > _priority.get(ns.banner_type, 0) %} {% set ns.banner_type = item.get('type','info') %} {% endif %} {% endfor %} {% set announcement_banner_type = ns.banner_type %} {% set ast_first_message = ast_items[0].get('message', '') if ast_items else '' %} {% set ast_first_url = ast_items[0].get('url', '') if ast_items else '' %}