From 663e797209b11d7d234ca90da82fb809ac688845 Mon Sep 17 00:00:00 2001 From: Karan Jayachandra Date: Fri, 18 Oct 2024 15:50:19 +0200 Subject: Made macros out of reused components --- templates/controls.j2 | 10 +++++----- templates/index.j2 | 41 ++++------------------------------------- templates/macros.j2 | 44 ++++++++++++++++++++++++++++++++++++++++++++ templates/players.j2 | 46 +++++----------------------------------------- 4 files changed, 58 insertions(+), 83 deletions(-) diff --git a/templates/controls.j2 b/templates/controls.j2 index 0b1451a..125dd38 100644 --- a/templates/controls.j2 +++ b/templates/controls.j2 @@ -1,10 +1,10 @@ {% from "macros.j2" import court %}
-
-{% for key, value in courts.items() %} - {{ court(key, value) }} -{% endfor %} -
+
+ {% for key, value in courts.items() %} + {{ court(key, value) }} + {% endfor %} +
diff --git a/templates/index.j2 b/templates/index.j2 index ff8f37a..832dbfb 100644 --- a/templates/index.j2 +++ b/templates/index.j2 @@ -1,46 +1,13 @@ +{% from "macros.j2" import header, footer, navbar %} - - - - Match Up! - - - - - + {{ header() }}
- + {{ navbar() }}
-
- Made by Karan using Flask, HTMX and Bulma -
+ {{ footer() }}
diff --git a/templates/macros.j2 b/templates/macros.j2 index 65d886f..58b1a73 100644 --- a/templates/macros.j2 +++ b/templates/macros.j2 @@ -20,4 +20,48 @@

⏲️ {{mins}}:{{secs}}

+{%- endmacro %} + +{% macro header() -%} + + + + Match Up! + + + + + +{%- endmacro %} + +{% macro footer() -%} +
Made by Karan using Flask, HTMX and Bulma
+{%- endmacro %} + +{% macro navbar() -%} + {%- endmacro %} \ No newline at end of file diff --git a/templates/players.j2 b/templates/players.j2 index 05f886a..6db040a 100644 --- a/templates/players.j2 +++ b/templates/players.j2 @@ -1,53 +1,17 @@ -{% from "macros.j2" import player %} +{% from "macros.j2" import header, navbar, footer, player %} - - - - Match Up! - - - - - + {{ header() }}
- + {{ navbar() }}
{% for id, value in players.items() %} -
- {{ player(id, value.status, value.name) }} -
+
{{ player(id, value.status, value.name) }}
{% endfor %}
-
- Made by Karan using Flask, HTMX and Bulma -
+ {{ footer() }}
\ No newline at end of file -- cgit v1.3.1