mirror of
https://github.com/Growstuff/growstuff.git
synced 2026-05-14 11:15:48 -04:00
Fix: Correct nutrition data rendering and add AFCD name
This commit addresses two issues in the nutritional data view:
1. **Fixes String Interpolation:** The HAML template incorrectly used an escaped hash (`\#{...}`) in string interpolations, which prevented the nutritional values from being rendered. This has been corrected by removing the backslash.
2. **Adds AFCD Name:** The view now displays the `food_name` from the Australian Food Classification Data to provide more context to the user.
This commit is contained in:
@@ -3,36 +3,36 @@
|
||||
.card
|
||||
.card-body
|
||||
%h4.card-title Nutritional Data
|
||||
%p.card-text A summary of nutritional data per 100g.
|
||||
%p.card-text A summary of nutritional data per 100g for #{data.food_name}.
|
||||
%table.table.table-sm.table-borderless
|
||||
%tbody
|
||||
- if data.energy_with_dietary_fibre_equated_kj.to_f > 0
|
||||
%tr
|
||||
%th Energy
|
||||
%td= "\#{data.energy_with_dietary_fibre_equated_kj.to_f.round(1)} kJ"
|
||||
%td= "#{data.energy_with_dietary_fibre_equated_kj.to_f.round(1)} kJ"
|
||||
- if data.protein_g.to_f > 0
|
||||
%tr
|
||||
%th Protein
|
||||
%td= "\#{data.protein_g.to_f.round(1)} g"
|
||||
%td= "#{data.protein_g.to_f.round(1)} g"
|
||||
- if data.fat_total_g.to_f > 0
|
||||
%tr
|
||||
%th Fat, total
|
||||
%td= "\#{data.fat_total_g.to_f.round(1)} g"
|
||||
%td= "#{data.fat_total_g.to_f.round(1)} g"
|
||||
- if data.available_carbohydrate_with_sugar_alcohols_g.to_f > 0
|
||||
%tr
|
||||
%th Carbohydrate
|
||||
%td= "\#{data.available_carbohydrate_with_sugar_alcohols_g.to_f.round(1)} g"
|
||||
%td= "#{data.available_carbohydrate_with_sugar_alcohols_g.to_f.round(1)} g"
|
||||
- if data.total_sugars_g.to_f > 0
|
||||
%tr
|
||||
%th - Sugars
|
||||
%td= "\#{data.total_sugars_g.to_f.round(1)} g"
|
||||
%td= "#{data.total_sugars_g.to_f.round(1)} g"
|
||||
- if data.total_dietary_fibre_g.to_f > 0
|
||||
%tr
|
||||
%th Fibre
|
||||
%td= "\#{data.total_dietary_fibre_g.to_f.round(1)} g"
|
||||
%td= "#{data.total_dietary_fibre_g.to_f.round(1)} g"
|
||||
- if data.sodium_na_mg.to_f > 0
|
||||
%tr
|
||||
%th Sodium
|
||||
%td= "\#{data.sodium_na_mg.to_f.round(1)} mg"
|
||||
%td= "#{data.sodium_na_mg.to_f.round(1)} mg"
|
||||
.card-footer
|
||||
= link_to "See more", "https://afcd.foodstandards.gov.au/fooddetails.aspx?PFKID=#{data.public_food_key}", target: "_blank", rel: "noopener noreferrer"
|
||||
|
||||
Reference in New Issue
Block a user