package pages import ( "fmt" "strings" . "recipe_book/pkg/db" ) func to_food_list(r Recipe) []Food { ret := make([]Food, len(r.Ingredients)) for i := range r.Ingredients { ret[i] = r.Ingredients[i].Food } return ret } templ RecipeDetail(recipe Recipe) {
Amount | Ingredient | Calories | Carbs | Protein | Fat | Sugar | for _, i := range recipe.Ingredients {|
---|---|---|---|---|---|---|---|
{ i.DisplayAmount() } | { i.Food.Name } | { fmt.Sprint(int(i.Food.Cals * i.Quantity)) } | { fmt.Sprint(int(i.Food.Carbs * i.Quantity)) } | { fmt.Sprint(int(i.Food.Protein * i.Quantity)) } | { fmt.Sprint(int(i.Food.Fat * i.Quantity)) } | { fmt.Sprint(int(i.Food.Sugar * i.Quantity)) } | |
Total | { fmt.Sprint(int(computed_food.Cals)) } | { fmt.Sprint(int(computed_food.Carbs)) } | { fmt.Sprint(int(computed_food.Protein)) } | { fmt.Sprint(int(computed_food.Fat)) } | { fmt.Sprint(int(computed_food.Sugar)) } |
{ line }
} }{ line }
}