From 01c3c4dd4bc90661455ecc7d9310a330aa9b2c97 Mon Sep 17 00:00:00 2001 From: Tim Abbott Date: Sat, 9 Dec 2023 12:16:54 -0800 Subject: [PATCH] template_parser: Handle else/elif with whitespace control. --- tools/lib/template_parser.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/tools/lib/template_parser.py b/tools/lib/template_parser.py index 76b8f69816..fc1d35643a 100644 --- a/tools/lib/template_parser.py +++ b/tools/lib/template_parser.py @@ -103,7 +103,12 @@ def tokenize(text: str, template_format: Optional[str] = None) -> List[Token]: return template_format == "django" and looking_at("{% ") def looking_at_django_else() -> bool: - return template_format == "django" and (looking_at("{% else") or looking_at("{% elif")) + return template_format == "django" and ( + looking_at("{% else") + or looking_at("{% elif") + or looking_at("{%- else") + or looking_at("{%- elif") + ) def looking_at_django_end() -> bool: return template_format == "django" and looking_at("{% end")