From a5b92f5672c4e9d34704858c1ddd4f21bfcd5eba Mon Sep 17 00:00:00 2001 From: vabene1111 Date: Sun, 4 Apr 2021 11:16:48 +0200 Subject: [PATCH] fixed template render issues --- cookbook/helper/template_helper.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/cookbook/helper/template_helper.py b/cookbook/helper/template_helper.py index 4eb4b98c4..d7189e3fb 100644 --- a/cookbook/helper/template_helper.py +++ b/cookbook/helper/template_helper.py @@ -3,8 +3,8 @@ import markdown as md from bleach_allowlist import markdown_attrs, markdown_tags from cookbook.helper.mdx_attributes import MarkdownFormatExtension from cookbook.helper.mdx_urlize import UrlizeExtension -from jinja2 import Template, TemplateSyntaxError - +from jinja2 import Template, TemplateSyntaxError, UndefinedError +from gettext import gettext as _ class IngredientObject(object): amount = "" @@ -57,6 +57,8 @@ def render_instructions(step): # TODO deduplicate markdown cleanup code template = Template(instructions) instructions = template.render(ingredients=ingredients) except TemplateSyntaxError: - pass + return _('Could not parse template code.') + ' Error: Template Syntax broken' + except UndefinedError: + return _('Could not parse template code.') + ' Error: Undefined Error' return instructions