From 22f7f6908ccc42df87ae2aa20a72b0792052e3af Mon Sep 17 00:00:00 2001 From: Justus Grunow Date: Sun, 26 Jan 2025 10:19:52 -0500 Subject: [PATCH] Greatly simplified the looping logic by removing an unnessary array level from the menu YAML --- build.py | 18 +++-- menu.yaml | 164 ++++++++++++++++++++++---------------------- templates/menu.html | 4 +- 3 files changed, 91 insertions(+), 95 deletions(-) diff --git a/build.py b/build.py index fc4bf23..a7c9234 100755 --- a/build.py +++ b/build.py @@ -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'
  • {ingredient[list(ingredient)[0]]} {list(ingredient)[0]}
  • ') - print(markdown.markdown(bev[name]['directions'])) - bev[name]['directions_html'] = markdown.markdown(bev[name]['directions']) + print(bev) + for ingredient in details['ingredients']: + print(f'
  • {ingredient[list(ingredient)[0]]} {list(ingredient)[0]}
  • ') + 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) diff --git a/menu.yaml b/menu.yaml index 988288b..4e4b2db 100644 --- a/menu.yaml +++ b/menu.yaml @@ -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 diff --git a/templates/menu.html b/templates/menu.html index a4d775d..8be838d 100644 --- a/templates/menu.html +++ b/templates/menu.html @@ -3,8 +3,7 @@ {% block bodyclass %}menu{% endblock %} {% block content %}

    {% block header %}Cocktails{% endblock %}

    -{% for bev in bevs %} - {% for name, details in bev.items() %} + {% for name, details in bevs.items() %}

    {{ name }}

    {% block directions scoped %}{% endblock %} {% endfor %} -{% endfor %} {% endblock %}