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") templateMenu = env.get_template("menu.html")
templateRecipes = env.get_template("recipes.html") templateRecipes = env.get_template("recipes.html")
for bev in menu['menu']: print(menu)
for bev, details in menu['menu'].items():
#print(bev) #print(bev)
for name in bev: print(bev)
print(name) for ingredient in details['ingredients']:
for ingredient in bev[name]['ingredients']:
print(f'<li>{ingredient[list(ingredient)[0]]} {list(ingredient)[0]}</li>') print(f'<li>{ingredient[list(ingredient)[0]]} {list(ingredient)[0]}</li>')
print(markdown.markdown(bev[name]['directions'])) print(markdown.markdown(details['directions']))
bev[name]['directions_html'] = markdown.markdown(bev[name]['directions']) details['directions_html'] = markdown.markdown(details['directions'])
with open('index.html', 'w') as file: with open('index.html', 'w') as file:
file.write(templateMenu.render(bevs = menu['menu'])) 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: with open('recipes.html', 'w') as file:
file.write(templateRecipes.render(bevs = menu['menu'])) file.write(templateRecipes.render(bevs = menu['menu']))
print(menu['menu'])
for ingredient in menu['out_of_stock']: for ingredient in menu['out_of_stock']:
print(ingredient) print(ingredient)

View File

@ -1,6 +1,6 @@
--- ---
menu: menu:
- Old Fashioned: Old Fashioned:
base: Bourbon base: Bourbon
category: Ancestrals category: Ancestrals
ingredients: ingredients:
@ -10,7 +10,7 @@ menu:
directions: | directions: |
1. Stir with ice. Strain into rocks glass over large cube. 1. Stir with ice. Strain into rocks glass over large cube.
1. Garnish with orange twist. 1. Garnish with orange twist.
- Boulevardier: Boulevardier:
base: Bourbon base: Bourbon
category: Spirit-Forward category: Spirit-Forward
ingredients: ingredients:
@ -20,7 +20,7 @@ menu:
directions: | directions: |
1. Stir with ice. Strain into rocks glass over large cube. 1. Stir with ice. Strain into rocks glass over large cube.
1. Garnish with orange twist. 1. Garnish with orange twist.
- Black Manhattan: Black Manhattan:
base: Rye whiskey base: Rye whiskey
category: Spirit-Forward category: Spirit-Forward
ingredients: ingredients:
@ -31,7 +31,7 @@ menu:
directions: | directions: |
1. Stir with ice. Strain into chilled coupe. 1. Stir with ice. Strain into chilled coupe.
1. Garnish with orange twist. 1. Garnish with orange twist.
- MonteNegroni: MonteNegroni:
base: Amaro Montenegro & Gin base: Amaro Montenegro & Gin
category: category:
ingredients: ingredients:
@ -42,7 +42,7 @@ menu:
directions: | directions: |
1. Stir with ice. Strain into rocks glass over large cube. 1. Stir with ice. Strain into rocks glass over large cube.
1. Garnish with orange twist. 1. Garnish with orange twist.
- Sidecar: Sidecar:
base: Bourbon base: Bourbon
category: Sours category: Sours
ingredients: ingredients:
@ -51,7 +51,7 @@ menu:
- Lemon juice: 0.5 oz - Lemon juice: 0.5 oz
directions: | directions: |
1. Shake with ice. Double strain into chilled coupe. 1. Shake with ice. Double strain into chilled coupe.
- "Gin & Tonic": "Gin & Tonic":
base: Gin base: Gin
category: Highballs category: Highballs
ingredients: ingredients:
@ -61,7 +61,7 @@ menu:
1. Pour gin and tonic over ice in short glass. 1. Pour gin and tonic over ice in short glass.
1. Stir gently. 1. Stir gently.
1. Garnish with lime wheel. 1. Garnish with lime wheel.
- Gimlet: Gimlet:
base: Gin base: Gin
category: Sours category: Sours
ingredients: ingredients:
@ -71,7 +71,7 @@ menu:
directions: | directions: |
1. Shake with ice. 1. Shake with ice.
1. Double strain into chilled coupe. 1. Double strain into chilled coupe.
- Bennet: Bennet:
base: Gin base: Gin
category: Sours category: Sours
ingredients: ingredients:

View File

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