Improve HTML Rendering

This commit is contained in:
L3D 2021-08-08 21:23:11 +02:00
parent 0f7cf7892d
commit 4fdc74717f
Signed by: l3d
GPG key ID: CD08445BFF4313D1
6 changed files with 195 additions and 140 deletions

View file

@ -34,6 +34,16 @@
{%- endif -%}
{{- '\n ' -}} </div>
{{- '\n ' -}} </div>
{#-
Render die Notizen und Angaben zur Verarbeitung der Rezepte
-#}
{%- if child.ingredients is defined and child.ingredients != "" %}
{%- if child.ingredients.blocks != [] -%}
{%- include "zutaten/zutat_notes.html" -%}
{%- endif -%}
{%- endif -%}
{#-
Nachdem die Zutaten des Rezept nun angegeben sind,

View file

@ -0,0 +1,70 @@
{#-
Wenn eine Zutat-Menge definiert ist, wird diese im folgenden for loop gerendert.
Sollte es unterschiedliche Teig-Mengen geben, ist die reinfolge der Zutatenmenge relevant.
Wenn also ein Rezept für 2 größen definiert ist, wird für die erste größe die erste Zutat genommen.
Und für die zweite größe die andere.
ABER, wenn eine der Zutat Null bzw. 0 ist, dann wird diese eine Zutat nicht gerendert.
-#}
{%- set ingredient_counter = loop.index -%}
{%- for amt in ing.amounts.blocks -%}
{%- if loop.index == prt_loop -%}
{%- if amt.amount is defined and amt.amount != "" and amt.amount != 0 and amt.amount != '0' and amt.amount != 'Null' -%}
{{- '\n ' -}} <li>
{{- '\n ' -}} <span
{%- if ing.usda_num is defined and ing.usda_num != "" -%}
{{- ' id=' -}}"usda_{{- ing.usda_num -}}"
{%- endif -%}
>{{ ing.ingredient }}: {{ amt.amount }} {{ amt.unit | default('each') }}</span>
{#-
Hier wird eine kurznotiz zur verarbeitung gerendert
oder ein Link zur Verarbeitungsnotiz.
-#}
{%- if ing.processing is defined and ing.processing != "" and ing.processing.blocks is defined and ing.processing.blocks != "" -%}
{%- if ing.processing.blocks != [] -%}
{%- for prc in ing.processing.blocks -%}
{%- if loop.index == 1 -%}
{%- if prc.short|default(False) -%}
{{- ' ' -}}
<i>({{ prc.process }})</i>
{%- else -%}
{{- ' ' -}}
<i>(<a href="#processing_{{- ing.ingredient | string -}}"_ class="processing">Angaben zur Verarbeitung von {{ ing.ingredient }} beachten</a>)</i>
{%- endif -%}
{%- endif -%}
{%- endfor -%}
{%- endif -%}
{%- endif -%}
{#-
Render alternativzutat, wenn verfügbar!
-#}
{%- if ing.substitutions is defined and ing.substitutions != "" -%}
{%- if ing.substitutions.blocks is defined and ing.substitutions.blocks != "" -%}
{%- if ing.substitutions.blocks != [] -%}
{%- for sst in ing.substitutions.blocks -%}
{%- if sst.amounts is defined and sst.amounts != "" and sst.amounts.blocks is defined and sst.amounts.blocks != "" -%}
{%- if sst.amounts.blocks != [] -%}
{%- for amt2 in sst.amounts.blocks -%}
{%- if loop.index == prt_loop -%}
{%- if amt2.amount is defined and amt2.amount != "" and amt2.amount != 0 and amt2.amount != '0' -%}
{{- ' ' -}}<i><span
{%- if sst.usda_num is defined and sst.usda_num != "" -%}
{{- ' id=' -}}"usda_{{- sst.usda_num -}}"
{%- endif -%}
>(alternativ {{ sst.ingredient }})</span></i>
{%- endif -%}
{%- endif -%}
{%- endfor -%}
{%- endif -%}
{%- endif -%}
{%- endfor -%}
{%- endif -%}
{%- endif -%}
{%- endif -%}
{{- '\n ' -}} </li>
{%- endif -%}
{%- endif -%}
{%- endfor -%}

View file

@ -0,0 +1,58 @@
{#-
Wenn keine Zutat-Menge definiert ist, wird statt dessen
in folgenden Loop nur die Zutat gerendert.
-#}
{{- '\n ' -}} <li>
{{- '\n ' -}} <span
{%- if ing.usda_num is defined and ing.usda_num != "" -%}
{{- ' id=' -}}"usda_{{- ing.usda_num -}}"
{%- endif -%}
>{{ ing.ingredient }}: nach belieben</span>
{#-
Hier wird eine kurznotiz zur verarbeitung gerendert
oder ein Link zur Verarbeitungsnotiz.
-#}
{%- if ing.processing is defined and ing.processing != "" and ing.processing.blocks is defined and ing.processing.blocks != "" -%}
{%- if ing.processing.blocks != [] -%}
{%- for prc in ing.processing.blocks -%}
{%- if loop.index == 1 -%}
{%- if prc.short|default(False) -%}
{{- ' ' -}}
<i>({{ prc.process }})</i>
{%- else -%}
{{- ' ' -}}
<i>(<a href="#processing_{{- ing.ingredient | string -}}"_ class="processing">Angaben zur Verarbeitung von {{ ing.ingredient }} beachten</a>)</i>
{%- endif -%}
{%- endif -%}
{%- endfor -%}
{%- endif -%}
{%- endif -%}
{#-
Render alternativzutat, wenn verfügbar!
-#}
{%- if ing.substitutions is defined and ing.substitutions != "" -%}
{%- if ing.substitutions.blocks is defined and ing.substitutions.blocks != "" -%}
{%- if ing.substitutions.blocks != [] -%}
{%- for sst in ing.substitutions.blocks -%}
{%- if sst.amounts is defined and sst.amounts != "" and sst.amounts.blocks is defined and sst.amounts.blocks != "" -%}
{%- if sst.amounts.blocks != [] -%}
{%- for amt2 in sst.amounts.blocks -%}
{%- if loop.index == prt_loop -%}
{%- if amt2.amount is defined and amt2.amount != "" and amt2.amount != 0 and amt2.amount != '0' -%}
{{- ' ' -}}<i><span
{%- if sst.usda_num is defined and sst.usda_num != "" -%}
{{- ' id=' -}}"usda_{{- sst.usda_num -}}"
{%- endif -%}
>(alternativ {{ sst.ingredient }})</span></i>
{%- endif -%}
{%- endif -%}
{%- endfor -%}
{%- endif -%}
{%- endif -%}
{%- endfor -%}
{%- endif -%}
{%- endif -%}
{%- endif -%}
{{- '\n ' -}} </li>

View file

@ -21,68 +21,15 @@
ABER, wenn eine der Zutat Null bzw. 0 ist, dann wird diese eine Zutat nicht gerendert.
-#}
{%- set ingredient_counter = loop.index -%}
{%- for amt in ing.amounts.blocks -%}
{%- if loop.index == prt_loop -%}
{%- if amt.amount is defined and amt.amount != "" and amt.amount != 0 and amt.amount != '0' and amt.amount != 'Null' -%}
{{- '\n ' -}} <li>
{{- '\n ' -}} <span
{%- if ing.usda_num is defined and ing.usda_num != "" -%}
{{- ' id=' -}}"usda_{{- ing.usda_num -}}"
{%- endif -%}
>{{ ing.ingredient }}: {{ amt.amount }} {{ amt.unit | default('each') }}</span>
{#-
Hier wird eine kurznotiz zur verarbeitung gerendert
oder ein Link zur Verarbeitungsnotiz.
-#}
{%- if ing.processing is defined and ing.processing != "" and ing.processing.blocks is defined and ing.processing.blocks != "" -%}
{%- if ing.processing.blocks != [] -%}
{%- for prc in ing.processing.blocks -%}
{%- if loop.index == 1 -%}
{%- if prc.short|default(False) -%}
{{- ' ' -}}
<i>({{ prc.process }})</i>
{%- else -%}
{{- ' ' -}}
<i>(<a href="#processing_{{- ing.ingredient | string -}}"_ class="processing">Angaben zur Verarbeitung von {{ ing.ingredient }} beachten</a>)</i>
{%- endif -%}
{%- endif -%}
{%- endfor -%}
{%- endif -%}
{%- endif -%}
{%- if ing.substitutions is defined and ing.substitutions != "" -%}
{%- if ing.substitutions.blocks is defined and ing.substitutions.blocks != "" -%}
{%- if ing.substitutions.blocks != [] -%}
{%- for sst in ing.substitutions.blocks -%}
{%- if sst.amounts is defined and sst.amounts != "" and sst.amounts.blocks is defined and sst.amounts.blocks != "" -%}
{%- if sst.amounts.blocks != [] -%}
{%- for amt2 in sst.amounts.blocks -%}
{%- if loop.index == prt_loop -%}
{%- if amt2.amount is defined and amt2.amount != "" and amt2.amount != 0 and amt2.amount != '0' -%}
{{- ' ' -}}<i><span
{%- if sst.usda_num is defined and sst.usda_num != "" -%}
{{- ' id=' -}}"usda_{{- sst.usda_num -}}"
{%- endif -%}
>(alternativ {{ sst.ingredient }})</span></i>
{%- endif -%}
{%- endif -%}
{%- endfor -%}
{%- endif -%}
{%- endif -%}
{%- endfor -%}
{%- endif -%}
{%- endif -%}
{%- endif -%}
{{- '\n ' -}} </li>
{%- endif -%}
{%- endif -%}
{%- endfor -%}
{%- include "zutaten/zutat_einzeln.html" -%}
{%- else -%}
{#-
Wenn eine Zutat keine klare Menge hat, wird diese ohne genaue größenangabe gerendert.
Wenn eine Zutat keine klare Menge hat,
wird diese hier ohne genaue größenangabe gerendert.
-#}
{%- include "zutaten/zutat_einzeln_ohne_menge.html" -%}
{%- endif -%}
{%- endif -%}
{%- endif -%}

View file

@ -1,66 +1,56 @@
{%- for ing1 in child.ingredients.blocks %}
{%- if ing1.ingredient is defined and ing1.ingredient != "" -%}
{%- if ing1.amounts is defined and ing1.amounts != "" and ing1.amounts.blocks is defined and ing1.amounts.blocks != "" -%}
{%- if ing1.amounts.blocks != [] -%}
{%- set ingredient_counter = loop.index -%}
{%- for amt in ing1.amounts.blocks -%}
{%- if loop.index == prt_loop -%}
{%- if amt.amount is defined and amt.amount != "" and amt.amount != 0 and amt.amount != '0' -%}
{%- if ing1.processing is defined and ing1.processing != "" and ing1.processing.blocks is defined and ing1.processing.blocks != "" -%}
{%- if ing1.processing.blocks != [] -%}
{{- '\n ' -}} <li>
{{- '\n ' -}}
<span id="processing_{{- ingredient_counter | string -}}" class="processing">Verarbeitungshinweis
{%- for tmp_prc in ing1.processing.blocks -%}
{%- if loop.index == 2 -%}
{{- 'e' -}}
{%- endif -%}
{%- endfor -%}
{{- ' #' -}}
{{- ingredient_counter | string -}}:</span>
{{- '\n ' -}}
<ul>
{%- for prc in ing1.processing.blocks -%}
{{- '\n ' -}} <li>
{{- '\n ' -}}
<span class="ingredientprocessing">{{ prc.process }}</span>
{{- '\n ' -}} </li>
{%- endfor -%}
{{- '\n ' -}} </ul>
{{- '\n ' -}} </li>
{{- '\n ' -}} </ul>
{%- endif -%}
{%- endif -%}
{%- if ing1.notes is defined and ing1.notes != "" and ing1.notes.blocks is defined and ing1.notes.blocks != "" -%}
{%- if ing1.notes.blocks != [] -%}
{{- '\n ' -}} <ul>
{{- '\n ' -}} <li>
{{- '\n ' -}}
<span id="note_{{- ingredient_counter | string -}}" class="ingredientnotes">Notiz
{%- for tmp_nde in ing1.notes.blocks -%}
{%- if loop.index == 2 -%}
{{- 'en' -}}
{%- endif -%}
{%- endfor -%}
{{- ' #' -}} {{- ingredient_counter | string -}}:</span>
{{- '\n ' -}}
<ul>
{%- for nde in ing1.notes.blocks -%}
{{- '\n ' -}} <li>
{{- '\n ' -}}
<span class="ingredientnotes">{{ nde.note }}</span>
{{- '\n ' -}} </li>
{%- endfor -%}
{{- '\n ' -}} </ul>
{{- '\n ' -}} </li>
{{- '\n ' -}} </ul>
{%- endif -%}
{%- endif -%}
{{- '\n ' -}} </li>
{%- endif -%}
{#-
Render die Notizen und Angaben zur Verarbeitung der Rezepte
-#}
{%- if child.ingredients is defined and child.ingredients != "" %}
{%- if child.ingredients.blocks != [] -%}
{{- '\n ' -}} <div class="content__box">
{{- '\n ' -}} <div class="content__inner_box">
{{- '\n ' -}} <h2>Hinweise zu den Zutaten</h2>
{%- for ing in child.ingredients.blocks %}
{%- if ing.ingredient is defined and ing.ingredient != "" -%}
{#-
Verarbeitungshinweise der Zutat
-#}
{%- if ing.processing is defined and ing.processing != "" -%}
{%- if ing.processing.blocks != [] -%}
{%- for prc in ing.processing.blocks -%}
{%- if not prc.short|default(false) -%}
{%- if loop.index == 1 -%}
{{- '\n ' -}} <h3 id="processing_{{- ing.ingredient | string -}}">Verarbeitung von {{ ing.ingredient }}:</h3>
{{- '\n ' -}} <ul>
{%- endif -%}
{%- endfor -%}
{%- endif -%}
{{- '\n ' -}} <li>
{{- '\n ' -}}
<span class="ingredientprocessing">{{ prc.process }}</span>
{{- '\n ' -}} </li>
{%- endif -%}
{%- endfor -%}
{{- '\n ' -}} </ul>
{%- endif -%}
{%- endif -%}
{%- endfor -%}
{#-
Notiz der Zutat
-#}
{%- if ing.notes is defined and ing.notes != "" -%}
{%- if ing.notes.blocks != [] -%}
{%- for nde in ing.notes.blocks -%}
{%- if loop.index == 1 -%}
{{- '\n ' -}} <h3 id="note_{{- ing.ingredient | string -}}">Notiz zu {{ ing.ingredient }}:</h3>
{{- '\n ' -}} <ul>
{%- endif -%}
{{- '\n ' -}} <li>
{{- '\n ' -}}
<span class="ingredientnote">{{ nde.note }}</span>
{{- '\n ' -}} </li>
{%- endfor -%}
{{- '\n ' -}} </ul>
{%- endif -%}
{%- endif -%}
{%- endif -%}
{%- endfor -%}
{{- '\n ' -}} </div>
{{- '\n ' -}} </div>
{%- endif -%}
{%- endif -%}

View file

@ -44,24 +44,4 @@
{%- endif -%}
{%- if child.ingredients is defined and child.ingredients != "" %}
{%- if child.ingredients.blocks != [] -%}
{{- '\n ' -}} <ul>
{%- include "zutaten/zutat_notes.html" -%}
{{- '\n ' -}} </ul>
{%- else -%}
{{- '\n ' -}} <ul>
{{- '\n ' -}} <span>Keine Zutaten definiert</span>
{{- '\n ' -}} </ul>
{%- endif -%}
{%- else -%}
{{- '\n ' -}} <ul>
{{- '\n ' -}} <span>Keine Zutaten definiert</span>
{{- '\n ' -}} </ul>
{%- endif -%}
{%- endfor -%}