pedf
/
fakulta-online
Archived
1
0
Fork 0

Výpis nástrojů pomocí makra

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.
master
Emil Miler 4 years ago
parent f0b9638611
commit 6af2af38a2

@ -0,0 +1,30 @@
{% macro print_tool(program) %}
<div class="program">
{% if program.extra.linkto and program.extra.directlink %}
<a href="{{ program.extra.linkto }}">
{% else %}
<a href="{{ program.permalink }}">
{% endif %}
<h4>{{ program.title }}</h4>
{% if program.extra.logo %}
<img src="/software/{{ program.extra.logo }}" alt="{{ program.title }}">
{% endif %}
</a>
<p>{{ program.description | safe }}</p>
{% if program.extra.positive_short and program.extra.negative_short %}
<div class="stats">
<ul class="positive">
{% for item in program.extra.positive_short %}
<li>{{ item }}</li>
{% endfor %}
</ul>
<ul class="negative">
{% for item in program.extra.negative_short %}
<li>{{ item }}</li>
{% endfor %}
</ul>
</div>
{% endif %}
</div>
{% endmacro print_tool %}

@ -1,4 +1,5 @@
{% extends "index.html" %}
{% import "macros.html" as macros %}
{% block content %}
<section class="meta">
@ -19,33 +20,16 @@
<section class="software">
{% for program in section.pages %}
{% if program.taxonomies.categories and program.taxonomies.categories is containing(page.slug) %}
<div class="program">
{% if program.extra.linkto and program.extra.directlink %}
<a href="{{ program.extra.linkto }}">
{% else %}
<a href="{{ program.permalink }}">
{% endif %}
<h4>{{ program.title }}</h4>
{% if program.extra.logo %}
<img src="/software/{{ program.extra.logo }}" alt="{{ program.title }}">
{% endif %}
</a>
<p>{{ program.description | safe }}</p>
{% if program.extra.positive_short and program.extra.negative_short %}
<div class="stats">
<ul class="positive">
{% for item in program.extra.positive_short %}
<li>{{ item }}</li>
{% endfor %}
</ul>
<ul class="negative">
{% for item in program.extra.negative_short %}
<li>{{ item }}</li>
{% endfor %}
</ul>
</div>
{% endif %}
</div>
{% 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 %}
</section>