I am trying to write a cooking receipe with Typst.
= Slow-Cooker Brisket
#figure(
table(
align: (auto, auto, left, auto),
columns: (auto, auto, auto, auto),
[*Ingredient*], [*Amount*], [*Unit*], [*Optional?*],
[Bourbon], [0.25], [cups], [False],
[Dijon Mustard], [2], [tablespoons], [False],
[Chilli Powder], [1], [tablespoons], [False],
[Vegetable Oil], [1], [tablespoons], [True],
),
)
I want to write code so that I don't have to write the same preamble over and over. However the code below fails on one_ingredient, saying unexpected comma.
#let one_ingredient(str_ingredient, float_amount, str_unit, bool_isoptional) = {
[#str_ingredient], [#float_amount], [#str_unit], [#bool_isoptional],
}
#let onerecipe(ingredient_array) = {
figure(
table(
align: (auto, auto, left, auto),
columns: (auto, auto, auto, auto),
[*Ingredient*], [*Amount*], [*Unit*], [*Optional?*],
for each_ingredient in ingredient_array {
one_ingredient(each_ingredient.at(0), each_ingredient.at(1), each_ingredient.at(2), each_ingredient.at(3))
}
)
)
}
= Slow-Cooker Brisket
onerecipe((("Bourbon", 0.25, "cups", False), ("Dijon Mustard", 2, "tablespoons", False), ("Chilli Powder", 1, "tablespoons", False), ("Vegetable Oil", 1, "tablespoons", True)))
Following that I rewrote my code eliminating one_ingredient but still got the same error.
#let onerecipe(ingredient_array) = {
figure(
table(
align: (auto, auto, left, auto),
columns: (auto, auto, auto, auto),
[*Ingredient*], [*Amount*], [*Unit*], [*Optional?*],
for each_ingredient in ingredient_array {
[each_ingredient.at(0)], [each_ingredient.at(1)], [each_ingredient.at(2)], [each_ingredient.at(3))]
}
)
)
}
How should I fix my code?