diff options
author | xengineering <me@xengineering.eu> | 2024-05-15 20:42:09 +0200 |
---|---|---|
committer | xengineering <me@xengineering.eu> | 2024-05-15 20:42:09 +0200 |
commit | d14aece3295405b4377ea20aabd9c621aace4922 (patch) | |
tree | 7c46946dcb0217511065acf722b246e412d45cac | |
parent | ae771a44c2ffe31dc1bd67a12b65849f7d7d2d11 (diff) | |
download | ceres-d14aece3295405b4377ea20aabd9c621aace4922.tar ceres-d14aece3295405b4377ea20aabd9c621aace4922.tar.zst ceres-d14aece3295405b4377ea20aabd9c621aace4922.zip |
view: Remove empty ingredient summaries
If the recipe has no ingredients at all the "Ingredient summary:" text
used to be displayed. This is not useful and confusing. It is removed
with this commit.
-rw-r--r-- | view/html/recipe.html | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/view/html/recipe.html b/view/html/recipe.html index 6d3ee0d..7abcad4 100644 --- a/view/html/recipe.html +++ b/view/html/recipe.html @@ -1,4 +1,10 @@ {{define "recipe"}} +{{- $hasIngredients := false -}} +{{- range .Steps -}} + {{- if gt (len .Ingredients) 0 -}} + {{- $hasIngredients = true -}} + {{- end -}} +{{- end -}} <!DOCTYPE html> <html> {{ template "head" }} @@ -15,12 +21,10 @@ <p class="notice" style="white-space: pre-line;">{{.Notes}}</p>{{end}}{{ if ne .Portions "" }} <p><i>Portions:</i> {{.Portions}}</p>{{end}}{{ if ne .Url "" }} <p><i>Original recipe:</i> <a href="{{.Url}}">link</a></p>{{end}} - <p><i>Ingredient summary:</i></p> - <ul> - {{range .Steps}}{{range $i, $el := .Ingredients}} - <li>{{if ne $el.Amount ""}}{{$el.Amount}} {{end}}{{if ne $el.Unit ""}}{{$el.Unit}} {{end}}{{$el.Type}}</li> - {{end}}{{end}} - </ul>{{range .Steps}} + {{if $hasIngredients}}<p><i>Ingredient summary:</i></p> + <ul>{{range .Steps}}{{range $i, $el := .Ingredients}} + <li>{{if ne $el.Amount ""}}{{$el.Amount}} {{end}}{{if ne $el.Unit ""}}{{$el.Unit}} {{end}}{{$el.Type}}</li>{{end}}{{end}} + </ul>{{end}}{{range .Steps}} <section> <p>{{.Text}}</p> <p><i>{{range $i, $el := .Ingredients}}{{if $i}}, {{end}}{{if ne $el.Amount ""}}{{$el.Amount}} {{end}}{{if ne $el.Unit ""}}{{$el.Unit}} {{end}}{{$el.Type}}{{end}}</i></p> |