From 9422e8194245c9cdbfa09b38c20173964349e2a2 Mon Sep 17 00:00:00 2001 From: xengineering Date: Thu, 24 Oct 2024 17:24:00 +0200 Subject: view: Order ingredient summary by ingredient name This makes it easier to write a shopping list for the required ingredients. --- view/html/recipe.html | 28 +++++++++++----------------- 1 file changed, 11 insertions(+), 17 deletions(-) (limited to 'view/html/recipe.html') diff --git a/view/html/recipe.html b/view/html/recipe.html index 7abcad4..cf30d06 100644 --- a/view/html/recipe.html +++ b/view/html/recipe.html @@ -1,30 +1,24 @@ {{define "recipe"}} -{{- $hasIngredients := false -}} -{{- range .Steps -}} - {{- if gt (len .Ingredients) 0 -}} - {{- $hasIngredients = true -}} - {{- end -}} -{{- end -}} {{ template "head" }}
{{ template "nav" }} -

{{.Title}}

+

{{.Recipe.Title}}

- - -

{{ if ne .Notes "" }} -

{{.Notes}}

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

Portions: {{.Portions}}

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

Original recipe: link

{{end}} - {{if $hasIngredients}}

Ingredient summary:

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

{{ if ne .Recipe.Notes "" }} +

{{.Recipe.Notes}}

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

Portions: {{.Recipe.Portions}}

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

Original recipe: link

{{end}}{{if .HasIngredients}} +

Ingredient summary:

+ {{end}}{{range .Recipe.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