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 --> <!-- Table for statistics of a variant -->
<div class="history-bullets"> <div class="history-bullets">
<ul class="stat-list"> <ul class="stat-list">
@ -49,3 +50,4 @@
</li> </li>
</ul> </ul>
</div> </div>
{% endmacro %}}

View file

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