-
Notifications
You must be signed in to change notification settings - Fork 0
/
view.py
31 lines (24 loc) · 1.33 KB
/
view.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
from jinja2 import Environment, PackageLoader, select_autoescape, FileSystemLoader
import model
class FoodHTMLView():
def __init__(self):
self.env = None
self.template = None
def initialise(self):
templateLoader = FileSystemLoader(searchpath="./view")
self.env = Environment(loader=templateLoader)
self.template = self.env.get_template("card_template_new.html")
def render(self, food : model.Food):
html = self.template.render(item_name = food.name,
energy = food.get_attribute("Energy"),
protein = food.get_attribute("Protein"),
carbohydrate = food.get_attribute("Carbohydrate"),
fat_total = food.get_attribute("Total Fat"),
fibre=food.get_attribute("Total Dietary Fibre"),
calcium=food.get_attribute("Calcium"),
iron=food.get_attribute("Iron"),
fat_saturated=food.get_attribute("Fat saturated"),
sugar=food.get_attribute("Total Sugar"),
salt=food.get_attribute("Sodium")
)
return(html)