From 21e68445e752940e75afc4b03374cb9493043322 Mon Sep 17 00:00:00 2001 From: Emi Vasilek Date: Fri, 17 Nov 2023 20:24:03 +0100 Subject: [PATCH] do not render price if unknown --- templates/base.html | 4 ++-- templates/index.html | 2 +- templates/recipe.html | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/templates/base.html b/templates/base.html index 27e990b..f3c4e83 100644 --- a/templates/base.html +++ b/templates/base.html @@ -1,5 +1,5 @@ -{% macro price(rec) -%} -{% if rec.price == None %}?{%else%}{{rec.price|round(1)|numprint}}{% endif %} CZK +{% macro price(price) -%} +{% if price == None %}?{%else%}{{price|round(1)|numprint}}{% endif %} CZK {%- endmacro %} diff --git a/templates/index.html b/templates/index.html index ada8bfd..9a38e25 100644 --- a/templates/index.html +++ b/templates/index.html @@ -3,6 +3,6 @@ {%block body %}

Recipes

{% for recipe in recipes %} -
  • {{price(recipe)}} {{ recipe.title }}
  • +
  • {% if recipe.price != None %}{{price(recipe.price)}} {%endif%}{{ recipe.title }}
  • {% endfor %} {%endblock%} diff --git a/templates/recipe.html b/templates/recipe.html index 7d09bbc..da71735 100644 --- a/templates/recipe.html +++ b/templates/recipe.html @@ -1,6 +1,6 @@ {% extends "base.html" %} {% macro ingredientpart(ing) -%} -{{price(ing)}} {{ing.amount|amountprint}} {{ing["unit"].name}} {{ ing.name }} {{ing.note}} +{% if recipe.price != None %}{{price(ing.price)}} {%endif%}{{ing.amount|amountprint}} {{ing["unit"].name}} {{ ing.name }} {{ing.note}} {%- endmacro %} {% macro ingredient(ing) -%} @@ -22,7 +22,7 @@ {% for ing in rec.ingredients %}
  • {{ingredient(ing)}}
  • {% endfor %} -price: {{ price(rec) }} +{% if recipe.price != None %}price: {{price(rec.price)}}{%endif%} {% endif %} {% if rec.steps|length != 0 %}

    Steps