add support for 'x to y z of ingredient' format

This commit is contained in:
Lynne Megido 2020-03-01 18:43:34 +10:00
parent 08c6a2c18c
commit f55dcebdb8
Signed by: lynnesbian
GPG key ID: F0A184B5213D9F90
2 changed files with 2 additions and 2 deletions

View file

@ -48,7 +48,7 @@ time: 240
- `name` (string) - The displayed name of the recipe. Does not appear in the URL. - `name` (string) - The displayed name of the recipe. Does not appear in the URL.
- `author` (string, optional) - The author of the recipe. - `author` (string, optional) - The author of the recipe.
- `ingredients` (list) - Each entry in `ingredients` is an array consisting of up to four items: - `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. - amount (number or array) - The amount of this item to add, e.g. `2` for 2 cups of flour. If this in an array, it will be printed as `amount[0] to amount[1]`. For example, if you wanted to say "2 to 3 cups of peas", you would write `[[2, 3], peas, cups]`.
- ingredient name (string) - The name of the ingredient, e.g. `flour` 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". - 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`. - 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`.

View file

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