From 74480cbe2b335fd141cdf5f07bb08808c0d08692 Mon Sep 17 00:00:00 2001 From: Karan Jayachandra Date: Wed, 16 Oct 2024 21:47:26 +0200 Subject: Added all macros and also stored the js, css, png and ico files --- templates/macros.j2 | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 templates/macros.j2 (limited to 'templates/macros.j2') diff --git a/templates/macros.j2 b/templates/macros.j2 new file mode 100644 index 0000000..b4767be --- /dev/null +++ b/templates/macros.j2 @@ -0,0 +1,11 @@ +{% macro court(id, status) -%} + +{%- endmacro %} + +{% macro player(id, status, name) -%} + +{%- endmacro %} \ No newline at end of file -- cgit v1.3.1 From 310c54caffb137af593e710b2437c2639863574d Mon Sep 17 00:00:00 2001 From: Karan Jayachandra Date: Wed, 16 Oct 2024 23:36:56 +0200 Subject: Added a few more j2 macros --- app.py | 6 ++++-- templates/macros.j2 | 12 ++++++++++++ 2 files changed, 16 insertions(+), 2 deletions(-) (limited to 'templates/macros.j2') diff --git a/app.py b/app.py index 22f6767..f145354 100644 --- a/app.py +++ b/app.py @@ -23,12 +23,14 @@ def home(): @app.route("/time", methods=["GET"]) def get_time(): mins, secs = rg.timer.get() - return render_template("time.j2", mins=mins, secs=secs) + t = re.from_string('{% from "macros.j2" import timer %}{{timer(mins, secs)}}') + return render_template(t, mins=mins, secs=secs) @app.route("/guests", methods=["GET"]) def get_guests(): - return render_template("guests.j2", guests=rg.players.guests) + t = re.from_string('{% from "macros.j2" import guests %}{{guests(count)}}') + return render_template(t, count=rg.players.guests) @app.route("/decrement", methods=["POST"]) diff --git a/templates/macros.j2 b/templates/macros.j2 index b4767be..7117d11 100644 --- a/templates/macros.j2 +++ b/templates/macros.j2 @@ -8,4 +8,16 @@ +{%- endmacro %} + +{% macro guests(count) -%} +
+ +
+{%- endmacro %} + +{% macro timer(mins, secs) -%} +
+

Timer: {{mins}}:{{secs}}

+
{%- endmacro %} \ No newline at end of file -- cgit v1.3.1