Compare commits

...

1 commit

Author SHA1 Message Date
Théophile Bastian 5f2c2f64f2 WIP much 2023-01-19 17:08:03 +01:00
2 changed files with 31 additions and 11 deletions

View file

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

View file

@ -1,25 +1,44 @@
<ul> <ul>
{{ $ingrRoot := 0 }}
{{- range . }}
{{ if isset . "percent" }}
{{ with .qt }}
{{ $ingrRoot := (int .) }}
{{ end }}
{{ end }}
{{ end -}}
{{- range . }} {{- range . }}
{{ if isset . "catname" }} {{ if isset . "catname" }}
</ul> </ul>
<h2>{{ .catname | markdownify }}</h2> <h2>{{ .catname | markdownify }}</h2>
{{- $prevIngrRoot := $ingrRoot -}}
{{ partial "ingredients_ul.html" .ingredients }} {{ partial "ingredients_ul.html" .ingredients }}
{{- $ingrRot := $prevIngrRoot -}}
<ul> <ul>
{{ else }} {{ else }}
<li> <li>
<span <span class="ingred-text">
class="ingred-qt{{ with .qt -}} <span
{{ if eq . "QS" }} with_abbrv" title="Quantité Suffisante{{ end }} class="ingred-qt{{ with .qt -}}
{{- end }}">{{ with .qt }}{{ . | markdownify }}{{ end }}</span> {{ if eq . "QS" }} with_abbrv" title="Quantité Suffisante{{ end }}
{{ with .article -}} {{- end }}">{{ with .qt }}{{ . | markdownify }}{{ end }}</span>
{{ . | markdownify -}} {{ with .article -}}
{{- if substr . -1 1 | eq "'" -}}{{ else }} {{ end -}} {{ . | markdownify -}}
{{/* ^^^ No space only if article ends with an apostrophe */}} {{- if substr . -1 1 | eq "'" -}}{{ else }} {{ end -}}
{{- end -}} {{/* ^^^ No space only if article ends with an apostrophe */}}
<span class="ingred-name">{{ .name | markdownify }}</span> {{- 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> </li>
{{ end }} {{ end }}
{{ end -}} {{ end -}}