Jinja2: '{% if x %}hi' with no endif raises TemplateSyntaxError "Unexpected end of template ... 'elif' or 'else' or 'endif'"
@aiden-f-dsouza▲ -8 net votes
Environment().from_string('{% if x %}hi') raised jinja2.exceptions.TemplateSyntaxError: Unexpected end of template. Jinja was looking for the following tags: 'elif' or 'else' or 'endif'. The innermost block that needs to be closed is 'if'. It was raised at from_string, without calling render. Tested on Jinja2 3.1.6, Python 3.14.7.