From f813ae5ac37a66535dc771dcc94915246cff08f6 Mon Sep 17 00:00:00 2001 From: Emi Vasilek Date: Sun, 5 Nov 2023 11:52:10 +0100 Subject: [PATCH] templates: use inheritance --- templates/base.html | 11 +++++++++++ templates/index.html | 14 ++++---------- templates/recipe.html | 42 ++++++++++++++++++------------------------ 3 files changed, 33 insertions(+), 34 deletions(-) create mode 100644 templates/base.html diff --git a/templates/base.html b/templates/base.html new file mode 100644 index 0000000..eb568e5 --- /dev/null +++ b/templates/base.html @@ -0,0 +1,11 @@ + + + + {% block title %}{% endblock %} + + + + + {% block body %}{% endblock %} + + \ No newline at end of file diff --git a/templates/index.html b/templates/index.html index 52b1116..48bd517 100644 --- a/templates/index.html +++ b/templates/index.html @@ -1,14 +1,8 @@ - - - - Recipes - - - - +{% extends "base.html" %} +{%block title%}Recipes{%endblock%} +{%block body %}

Recipes

{% for recipe in recipes %}
  • {{ recipe.title }}
  • {% endfor %} - - \ No newline at end of file +{%endblock%} \ No newline at end of file diff --git a/templates/recipe.html b/templates/recipe.html index 7cbc227..8a97614 100644 --- a/templates/recipe.html +++ b/templates/recipe.html @@ -1,3 +1,4 @@ +{% extends "base.html" %} {% macro ingredientpart(ing) -%} {{ing.amount}} {{ing.unit.name}} {{ ing.name }} {%- endmacro %} @@ -9,27 +10,20 @@ {% endfor %} {% endif %} {%- endmacro %} - - - - {{recipe.title}} - - - - - back -

    {{recipe.title}}

    - {% for part in recipe.parts %} -

    {{part.title}}

    -

    Ingredients

    - {% for ing in part.ingredients %} -
  • {{ingredient(ing)}}
  • - {% endfor %} -

    Steps

    - {% for step in part.steps %} -
  • {{ step }}
  • - {% endfor %} -
    - {% endfor %} - - \ No newline at end of file +{%block title%}{{recipe.title}}{%endblock%} +{%block body %} +back +

    {{recipe.title}}

    +{% for part in recipe.parts %} +

    {{part.title}}

    +

    Ingredients

    +{% for ing in part.ingredients %} +
  • {{ingredient(ing)}}
  • +{% endfor %} +

    Steps

    +{% for step in part.steps %} +
  • {{ step }}
  • +{% endfor %} +
    +{% endfor %} +{%endblock%} \ No newline at end of file