simplify: use jinja macro

This commit is contained in:
Maximilian Keßler 2023-12-05 18:30:15 +01:00
parent 89a14b6bc1
commit c9c4e3aec6
Signed by: max
GPG key ID: BCC5A619923C0BA5
2 changed files with 8 additions and 9 deletions

View file

@ -1,3 +1,4 @@
{% macro stats_list(stats, show_rating) %}
<!-- Table for statistics of a variant -->
<div class="history-bullets">
<ul class="stat-list">
@ -48,4 +49,5 @@
{{stats.average_moves}}
</li>
</ul>
</div>
</div>
{% endmacro %}}

View file

@ -1,4 +1,5 @@
{% extends "layout.html" %}
{% from "stats_table.html" import stats_list %}
{% block navbar %}
<nav class="navbar navbar-expand-lg navbar-light bg-light">
@ -31,25 +32,21 @@
<h3>
League Statistics for {{variant_name}}
</h3>
{% with stats=variant_stats, show_rating=False %}
{% include "stats_table.html" %}
{% endwith %}
{{ stats_list(variant_stats, False) }}
</div>
</div>
{% for num_players, stats in variant_stats_by_player.items() %}
{% for num_players, num_player_stats in variant_stats_by_player.items() %}
<div class="tab-pane fade" id="stats-{{num_players}}p">
<div class="container my-5">
<h3>
League Statistics for {{variant_name}} - {{num_players}} Players
</h3>
{% with show_rating=True %}
{% include "stats_table.html" %}
{% endwith %}
{{ stats_list(num_player_stats, True) }}
<h4>
List of Played Games
</h4>
{% if stats.games_played == 0 %}
{% if num_player_stats.games_played == 0 %}
There have been no games played on this variant with {{num_players}} players so far.
{% else %}
<div id="table-{{num_players}}p"></div>