diff --git a/cookbook/helper/template_helper.py b/cookbook/helper/template_helper.py index 016779a7..4db1f5bc 100644 --- a/cookbook/helper/template_helper.py +++ b/cookbook/helper/template_helper.py @@ -14,12 +14,14 @@ class IngredientObject(object): unit = "" food = "" note = "" + numeric_amount = 0 def __init__(self, ingredient): if ingredient.no_amount: self.amount = "" else: self.amount = f"" + self.numeric_amount = float(ingredient.amount) if ingredient.unit: if ingredient.unit.plural_name in (None, ""): self.unit = bleach.clean(str(ingredient.unit)) @@ -83,9 +85,12 @@ def render_instructions(step): # TODO deduplicate markdown cleanup code for i in step.ingredients.all(): ingredients.append(IngredientObject(i)) + def scale(number): + return f"" + try: template = Template(instructions) - instructions = template.render(ingredients=ingredients) + instructions = template.render(ingredients=ingredients, scale=scale) except TemplateSyntaxError: return _('Could not parse template code.') + ' Error: Template Syntax broken' except UndefinedError: