SielBotWebsite/templates/macros.html
2026-09-29 06:34:54 +02:00

20 lines
971 B
HTML
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

{# Auswahlliste fuer Textkanaele, gruppiert nach Kategorie #}
{% macro channel_select(name, channels, selected, types=("text", "news"), empty="– keiner –") %}
{% set cats = channels | selectattr("type", "equalto", "category") | list %}
<select name="{{ name }}">
<option value="">{{ empty }}</option>
{% for ch in channels if ch.type in types and not ch.category_id %}
<option value="{{ ch.id }}"{% if ch.id == selected %} selected{% endif %}># {{ ch.name }}</option>
{% endfor %}
{% for cat in cats %}
{% set inner = channels | selectattr("category_id", "equalto", cat.id) | selectattr("type", "in", types) | list %}
{% if inner %}
<optgroup label="{{ cat.name }}">
{% for ch in inner %}
<option value="{{ ch.id }}"{% if ch.id == selected %} selected{% endif %}># {{ ch.name }}</option>
{% endfor %}
</optgroup>
{% endif %}
{% endfor %}
</select>
{% endmacro %}