From 07b69dab9045aa7b2dd41804ecb0eafd51defdcb Mon Sep 17 00:00:00 2001 From: "Jose M. Guisado" Date: Tue, 22 Feb 2022 12:34:03 +0100 Subject: Merge nav into base template {% block %} defined in nav template cannot be overriden by child templates from base. This is a limitation in jinja. Merge nav into base template so jinja blocks so no {% include %} is used and these blocks can be overriden by child templates (commands, images, dashboard...) Avoid using request.endpoint to determine active nav item, decoupling endpoint names from navigation. Instead use child templates to override jinja blocks. [1] https://stackoverflow.com/q/40537752 https://stackoverflow.com/a/40562662 https://github.com/pallets/jinja/issues/243 --- ogcp/templates/base.html | 49 +++++++++++++++++++++++++++++++++++++++++-- ogcp/templates/commands.html | 2 +- ogcp/templates/dashboard.html | 2 ++ ogcp/templates/nav.html | 47 ----------------------------------------- 4 files changed, 50 insertions(+), 50 deletions(-) delete mode 100644 ogcp/templates/nav.html (limited to 'ogcp') diff --git a/ogcp/templates/base.html b/ogcp/templates/base.html index 68e2e64..c6c3e3b 100644 --- a/ogcp/templates/base.html +++ b/ogcp/templates/base.html @@ -15,8 +15,53 @@
- {% include 'nav.html' %} - {% block nav %}{% endblock %} +
{% block container %}
diff --git a/ogcp/templates/commands.html b/ogcp/templates/commands.html index ac41354..28ad9b0 100644 --- a/ogcp/templates/commands.html +++ b/ogcp/templates/commands.html @@ -1,7 +1,7 @@ {% extends 'base.html' %} {% import "macros.html" as macros %} -{% block nav_scopes %}active{% endblock %} +{% block nav_commands %}active{% endblock %} {% block container %}
diff --git a/ogcp/templates/dashboard.html b/ogcp/templates/dashboard.html index 21d1d70..75f4cb6 100644 --- a/ogcp/templates/dashboard.html +++ b/ogcp/templates/dashboard.html @@ -1,5 +1,7 @@ {% extends 'base.html' %} +{% block nav_dashboard %}active{% endblock %} + {% block content %}
diff --git a/ogcp/templates/nav.html b/ogcp/templates/nav.html deleted file mode 100644 index edf5c05..0000000 --- a/ogcp/templates/nav.html +++ /dev/null @@ -1,47 +0,0 @@ - -- cgit v1.2.3-18-g5258