add support for optional ingredients

This commit is contained in:
Lynne Megido 2020-03-01 18:38:27 +10:00
parent 4b6d04ee6b
commit 08c6a2c18c
Signed by: lynnesbian
GPG Key ID: F0A184B5213D9F90
3 changed files with 12 additions and 3 deletions

View File

@ -47,7 +47,11 @@ time: 240
```
- `name` (string) - The displayed name of the recipe. Does not appear in the URL.
- `author` (string, optional) - The author of the recipe.
- `ingredients` (list) - Each entry in `ingredients` consists of an amount, ingredient name, and unit terminology. `[2, flour, cups]` is displayed as `2 cups of flour`, while `[1, egg, null]` is displayed as `1 egg`. The third field is optional - `[1, egg, null]` is the same as `[1, egg]`.
- `ingredients` (list) - Each entry in `ingredients` is an array consisting of up to four items:
- amount (number) - The amount of this item to add, e.g. `2` for 2 cups of flour.
- ingredient name (string) - The name of the ingredient, e.g. `flour` for 2 cups of flour.
- unit terminology (string, optional) - The unit that amount refers to, e.g. `cups` for 2 cups of flour. If left blank or null, as in `[1, egg]`, the output will simply be "1 egg".
- optional (boolean, optional) - Whether or not this ingredient is optional. The ingredient `[1, chocolate egg, null, true]` produces "1 chocolate egg" and marks is as optional. Defaults to `false`.
- `method` (list) - A list of steps undertaken to create the recipe, written in plain English. Or whatever language you prefer.
- `time` (string, optional) - The time it takes to make the recipe in minutes.

View File

@ -3,8 +3,8 @@
{%- assign tag = "h4" -%}
{%- endif -%}
<{{tag}}>Ingredients</{{tag}}>
<ul>
<ul class='ingredients'>
{% for item in page.ingredients -%}
<li>{{ item[0] }} {%- if item[2] %} {{ item[2] }} of {%- endif %} {{ item[1] }}</li>
<li class='{% if item[3] %}optional{% endif %}'>{{ item[0] }} {%- if item[2] %} {{ item[2] }} of {%- endif %} {{ item[1] }}</li>
{% endfor -%}
</ul>

View File

@ -35,6 +35,11 @@ h4 {
margin: 0.75em 0;
}
.ingredients li.optional::before {
content: "(Optional) ";
font-style: italic;
}
.subrecipe {
background: #eee;
padding: 10px;