Greatly simplified the looping logic by removing an unnessary array

level from the menu YAML
This commit is contained in:
Justus Grunow 2025-01-26 10:19:52 -05:00
parent 80190a3669
commit 22f7f6908c
3 changed files with 91 additions and 95 deletions

View File

@ -13,14 +13,15 @@ with open('menu.yaml', 'r') as file:
templateMenu = env.get_template("menu.html")
templateRecipes = env.get_template("recipes.html")
for bev in menu['menu']:
print(menu)
for bev, details in menu['menu'].items():
#print(bev)
for name in bev:
print(name)
for ingredient in bev[name]['ingredients']:
print(f'<li>{ingredient[list(ingredient)[0]]} {list(ingredient)[0]}</li>')
print(markdown.markdown(bev[name]['directions']))
bev[name]['directions_html'] = markdown.markdown(bev[name]['directions'])
print(bev)
for ingredient in details['ingredients']:
print(f'<li>{ingredient[list(ingredient)[0]]} {list(ingredient)[0]}</li>')
print(markdown.markdown(details['directions']))
details['directions_html'] = markdown.markdown(details['directions'])
with open('index.html', 'w') as file:
file.write(templateMenu.render(bevs = menu['menu']))
@ -28,8 +29,5 @@ with open('index.html', 'w') as file:
with open('recipes.html', 'w') as file:
file.write(templateRecipes.render(bevs = menu['menu']))
print(menu['menu'])
for ingredient in menu['out_of_stock']:
print(ingredient)

164
menu.yaml
View File

@ -1,87 +1,87 @@
---
menu:
- Old Fashioned:
base: Bourbon
category: Ancestrals
ingredients:
- Bourbon: 2 oz
- Maple syrup: 1tsp
- Angostura bitters: 2 dashes
directions: |
1. Stir with ice. Strain into rocks glass over large cube.
1. Garnish with orange twist.
- Boulevardier:
base: Bourbon
category: Spirit-Forward
ingredients:
- Bourbon: 1.5 oz
- Campari: 1 oz
- Sweet vermouth: 1 oz
directions: |
1. Stir with ice. Strain into rocks glass over large cube.
1. Garnish with orange twist.
- Black Manhattan:
base: Rye whiskey
category: Spirit-Forward
ingredients:
- Rye whiskey: 2 oz
- Amaro: 1 oz
- Angostura bitters: 1 dash
- Orange bitters: 1 dash
directions: |
1. Stir with ice. Strain into chilled coupe.
1. Garnish with orange twist.
- MonteNegroni:
base: Amaro Montenegro & Gin
category:
ingredients:
- Amaro Montenegro: 1 1/3 oz
- Gin: 2/3 oz
- Sweet vermouth: 2/3 oz
- Angostura bitters: 2 drops
directions: |
1. Stir with ice. Strain into rocks glass over large cube.
1. Garnish with orange twist.
- Sidecar:
base: Bourbon
category: Sours
ingredients:
- Bourbon: 2 oz
- Cointreau: 1 oz
- Lemon juice: 0.5 oz
directions: |
1. Shake with ice. Double strain into chilled coupe.
- "Gin & Tonic":
base: Gin
category: Highballs
ingredients:
- Gin: 2 oz
- Tonic water: 4 oz
directions: |
1. Pour gin and tonic over ice in short glass.
1. Stir gently.
1. Garnish with lime wheel.
- Gimlet:
base: Gin
category: Sours
ingredients:
- Gin: 2 oz
- Lime juice: 1 oz
- Simple syrup: 0.5 oz
directions: |
1. Shake with ice.
1. Double strain into chilled coupe.
- Bennet:
base: Gin
category: Sours
ingredients:
- Gin: 2 oz
- Lime juice: 1 oz
- Simple syrup: 0.5 oz
- Angostura bitters: 1 dash
directions: |
1. Shake with ice.
1. Double strain into chilled coupe.
Old Fashioned:
base: Bourbon
category: Ancestrals
ingredients:
- Bourbon: 2 oz
- Maple syrup: 1tsp
- Angostura bitters: 2 dashes
directions: |
1. Stir with ice. Strain into rocks glass over large cube.
1. Garnish with orange twist.
Boulevardier:
base: Bourbon
category: Spirit-Forward
ingredients:
- Bourbon: 1.5 oz
- Campari: 1 oz
- Sweet vermouth: 1 oz
directions: |
1. Stir with ice. Strain into rocks glass over large cube.
1. Garnish with orange twist.
Black Manhattan:
base: Rye whiskey
category: Spirit-Forward
ingredients:
- Rye whiskey: 2 oz
- Amaro: 1 oz
- Angostura bitters: 1 dash
- Orange bitters: 1 dash
directions: |
1. Stir with ice. Strain into chilled coupe.
1. Garnish with orange twist.
MonteNegroni:
base: Amaro Montenegro & Gin
category:
ingredients:
- Amaro Montenegro: 1 1/3 oz
- Gin: 2/3 oz
- Sweet vermouth: 2/3 oz
- Angostura bitters: 2 drops
directions: |
1. Stir with ice. Strain into rocks glass over large cube.
1. Garnish with orange twist.
Sidecar:
base: Bourbon
category: Sours
ingredients:
- Bourbon: 2 oz
- Cointreau: 1 oz
- Lemon juice: 0.5 oz
directions: |
1. Shake with ice. Double strain into chilled coupe.
"Gin & Tonic":
base: Gin
category: Highballs
ingredients:
- Gin: 2 oz
- Tonic water: 4 oz
directions: |
1. Pour gin and tonic over ice in short glass.
1. Stir gently.
1. Garnish with lime wheel.
Gimlet:
base: Gin
category: Sours
ingredients:
- Gin: 2 oz
- Lime juice: 1 oz
- Simple syrup: 0.5 oz
directions: |
1. Shake with ice.
1. Double strain into chilled coupe.
Bennet:
base: Gin
category: Sours
ingredients:
- Gin: 2 oz
- Lime juice: 1 oz
- Simple syrup: 0.5 oz
- Angostura bitters: 1 dash
directions: |
1. Shake with ice.
1. Double strain into chilled coupe.
out_of_stock:
- Rye whiskey

View File

@ -3,8 +3,7 @@
{% block bodyclass %}menu{% endblock %}
{% block content %}
<h1>{% block header %}Cocktails{% endblock %}</h1>
{% for bev in bevs %}
{% for name, details in bev.items() %}
{% for name, details in bevs.items() %}
<h2>{{ name }}</h2>
<ul>
{% for ingredient in details['ingredients'] %}
@ -15,5 +14,4 @@
</ul>
{% block directions scoped %}{% endblock %}
{% endfor %}
{% endfor %}
{% endblock %}