From bf328dd38a28cf44cfa81c7f1dcd95936d2d0301 Mon Sep 17 00:00:00 2001
From: xengineering
Date: Sun, 7 Apr 2024 12:04:11 +0200
Subject: view: Add ingredient overview to recipe read page
---
model/recipe.go | 8 ++++++--
view/html/recipe.html | 12 +++++++++---
2 files changed, 15 insertions(+), 5 deletions(-)
diff --git a/model/recipe.go b/model/recipe.go
index 7f8a1d5..7aebad4 100644
--- a/model/recipe.go
+++ b/model/recipe.go
@@ -260,11 +260,15 @@ func RecipeTestData() []Recipe {
{Amount: "4", Unit: "pieces", Type: "egg"},
{Amount: "800", Unit: "g", Type: "special stuff"},
{Amount: "0.5", Unit: "l", Type: "milk"},
- {Amount: "", Unit: "", Type: "salt"},
},
},
{Text: "Heat up pan", Ingredients: []Ingredient{}},
- {Text: "Make pancakes!", Ingredients: []Ingredient{}},
+ {
+ Text: "Make pancakes!",
+ Ingredients: []Ingredient{
+ {Amount: "", Unit: "", Type: "sugar"},
+ },
+ },
},
},
{
diff --git a/view/html/recipe.html b/view/html/recipe.html
index 3d9ab63..d794b9d 100644
--- a/view/html/recipe.html
+++ b/view/html/recipe.html
@@ -11,10 +11,16 @@
-
{{ if ne .Portions "" }}
+
{{ if ne .Notes "" }}
+ {{.Notes}}
{{end}}{{ if ne .Portions "" }}
Portions: {{.Portions}}
{{end}}{{ if ne .Url "" }}
- Original recipe: link
{{end}}{{ if ne .Notes "" }}
- {{.Notes}}
{{end}}{{range .Steps}}
+ Original recipe: link
{{end}}
+ Ingredients:
+
+ {{range .Steps}}{{range $i, $el := .Ingredients}}
+ - {{if ne $el.Amount ""}}{{$el.Amount}} {{end}}{{if ne $el.Unit ""}}{{$el.Unit}} {{end}}{{$el.Type}}
+ {{end}}{{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