From d14aece3295405b4377ea20aabd9c621aace4922 Mon Sep 17 00:00:00 2001 From: xengineering Date: Wed, 15 May 2024 20:42:09 +0200 Subject: 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. --- view/html/recipe.html | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) (limited to 'view') 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 -}} {{ template "head" }} @@ -15,12 +21,10 @@

{{.Notes}}

{{end}}{{ if ne .Portions "" }}

Portions: {{.Portions}}

{{end}}{{ if ne .Url "" }}

Original recipe: link

{{end}} -

Ingredient summary:

- {{range .Steps}} + {{if $hasIngredients}}

Ingredient summary:

+ {{end}}{{range .Steps}}

{{.Text}}

{{range $i, $el := .Ingredients}}{{if $i}}, {{end}}{{if ne $el.Amount ""}}{{$el.Amount}} {{end}}{{if ne $el.Unit ""}}{{$el.Unit}} {{end}}{{$el.Type}}{{end}}

-- cgit v1.2.3-70-g09d2