From 6af2af38a2c8c7272a2e2ef3d9950ceeb8285054 Mon Sep 17 00:00:00 2001 From: Emil Miler Date: Wed, 14 Oct 2020 09:02:04 +0200 Subject: [PATCH] =?UTF-8?q?V=C3=BDpis=20n=C3=A1stroj=C5=AF=20pomoc=C3=AD?= =?UTF-8?q?=20makra?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Aby bylo možné, dle požadavku, řadit nástroje podle toho, jestli mají seznam pozitiv a negativ, je třeba vypisovat je ve dvou cyklech. Aby se neopakoval kód v šabloně, probíhá vypsání nástroje pomocí makra. --- templates/macros.html | 30 ++++++++++++++++++++++++++++++ templates/page.html | 38 +++++++++++--------------------------- 2 files changed, 41 insertions(+), 27 deletions(-) create mode 100644 templates/macros.html diff --git a/templates/macros.html b/templates/macros.html new file mode 100644 index 0000000..4cbd05c --- /dev/null +++ b/templates/macros.html @@ -0,0 +1,30 @@ +{% macro print_tool(program) %} +
+ {% if program.extra.linkto and program.extra.directlink %} + + {% else %} + + {% endif %} +

{{ program.title }}

+ {% if program.extra.logo %} + {{ program.title }} + {% endif %} +
+

{{ program.description | safe }}

+ {% if program.extra.positive_short and program.extra.negative_short %} +
+
    + {% for item in program.extra.positive_short %} +
  • {{ item }}
  • + {% endfor %} +
+
    + {% for item in program.extra.negative_short %} +
  • {{ item }}
  • + {% endfor %} +
+
+ {% endif %} +
+{% endmacro print_tool %} + diff --git a/templates/page.html b/templates/page.html index bdbe675..43ee733 100644 --- a/templates/page.html +++ b/templates/page.html @@ -1,4 +1,5 @@ {% extends "index.html" %} +{% import "macros.html" as macros %} {% block content %}
@@ -19,33 +20,16 @@
{% for program in section.pages %} {% if program.taxonomies.categories and program.taxonomies.categories is containing(page.slug) %} -
- {% if program.extra.linkto and program.extra.directlink %} - - {% else %} - - {% endif %} -

{{ program.title }}

- {% if program.extra.logo %} - {{ program.title }} - {% endif %} -
-

{{ program.description | safe }}

- {% if program.extra.positive_short and program.extra.negative_short %} -
-
    - {% for item in program.extra.positive_short %} -
  • {{ item }}
  • - {% endfor %} -
-
    - {% for item in program.extra.negative_short %} -
  • {{ item }}
  • - {% endfor %} -
-
- {% endif %} -
+ {% if program.extra.positive_short and program.extra.negative_short %} + {{ macros::print_tool(program=program) }} + {% endif %} + {% endif %} + {% endfor %} + {% for program in section.pages %} + {% if program.taxonomies.categories and program.taxonomies.categories is containing(page.slug) %} + {% if not program.extra.positive_short or not program.extra.negative_short %} + {{ macros::print_tool(program=program) }} + {% endif %} {% endif %} {% endfor %}