This commit is contained in:
Théophile Bastian 2023-01-19 17:08:03 +01:00
parent b86507621e
commit 5f2c2f64f2
2 changed files with 31 additions and 11 deletions

View file

@ -10,6 +10,7 @@ ingredients:
- qt: 250g
article: de
name: farine (T45 de préférence)
percent: true
- qt: 6g
article: de
name: levure boulangère fraîche

View file

@ -1,15 +1,25 @@
<ul>
{{ $ingrRoot := 0 }}
{{- range . }}
{{ if isset . "percent" }}
{{ with .qt }}
{{ $ingrRoot := (int .) }}
{{ end }}
{{ end }}
{{ end -}}
{{- range . }}
{{ if isset . "catname" }}
</ul>
<h2>{{ .catname | markdownify }}</h2>
{{- $prevIngrRoot := $ingrRoot -}}
{{ partial "ingredients_ul.html" .ingredients }}
{{- $ingrRot := $prevIngrRoot -}}
<ul>
{{ else }}
<li>
<span class="ingred-text">
<span
class="ingred-qt{{ with .qt -}}
{{ if eq . "QS" }} with_abbrv" title="Quantité Suffisante{{ end }}
@ -20,6 +30,15 @@
{{/* ^^^ No space only if article ends with an apostrophe */}}
{{- end -}}
<span class="ingred-name">{{ .name | markdownify }}</span>
</span>
<span class="ingred-baker-percent">
{{ if not eq $ingrRoot.percent 0 -}}
{{ with .qt }}
{{ if not eq . "QS" }}
{{ mul 100 (div . $ingrRoot.percent) }} %
{{ end }}
{{ end }}
{{- end }}
</li>
{{ end }}
{{ end -}}