{# ══════════════════════════════════════════════════════════════════ Shared leaderboard macros: period tabs + one window table. All three windows (global / weekly / monthly) are rendered server-side and toggled client-side → instant, zero loading. Import with context: {% from "webapp/_lb_macros.html" import ... with context %} ══════════════════════════════════════════════════════════════════ #} {% macro lb_tabs(active='global') %}
{% endmacro %} {% macro lb_table(rows, me_id=None, hint='') %} {% if rows %} {% if hint %}
{{ hint }}
{% endif %}
{% for e in rows %} {% set is_me = me_id is not none and e.user_id == me_id %} {% endfor %}
{{ t('rank') | default('RANK') }} {{ t('player') | default('PLAYER') }} {{ t('wins') | default('WINS') }} {{ t('points') | default('POINTS') }} {{ t('win_rate') | default('WIN RATE') }} {{ t('prize') | default('PRIZE') }}
{% if loop.index0 == 0 %}🥇{% elif loop.index0 == 1 %}🥈{% elif loop.index0 == 2 %}🥉{% else %}{{ loop.index0 + 1 }}{% endif %}
{{ (e.user.display_name[0]|upper) if e.user and e.user.display_name else '?' }}
{% if e.user and e.user.numeric_id is not none %} {{ e.user.display_name }} {% else %} {{ 'Player #' ~ e.user_id }} {% endif %} {% if is_me %}{{ t('you') | default('YOU') }}{% endif %}
🎮 {{ e.matches }} {{ t('lb_match_one') if e.matches == 1 else t('lb_match_many') }} · 🏆 {{ e.wins }} {{ t('lb_win_one') if e.wins == 1 else t('lb_win_many') }}
{{ e.wins }} {{ e.points }} {{ e.win_rate }}% ${{ '%.2f' | format(e.prize) }}
{% else %}
📊

{{ t('no_data') | default('No data available') }}

{{ hint if hint else (t('no_leaderboard_data') | default('Leaderboard data is not available yet.')) }}

{% endif %} {% endmacro %} {% macro lb_script() %} {% endmacro %}