template_parser: Handle else/elif with whitespace control.

This commit is contained in:
Tim Abbott 2023-12-09 12:16:54 -08:00
parent f86becfc94
commit 01c3c4dd4b
1 changed files with 6 additions and 1 deletions

View File

@ -103,7 +103,12 @@ def tokenize(text: str, template_format: Optional[str] = None) -> List[Token]:
return template_format == "django" and looking_at("{% ") return template_format == "django" and looking_at("{% ")
def looking_at_django_else() -> bool: 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: def looking_at_django_end() -> bool:
return template_format == "django" and looking_at("{% end") return template_format == "django" and looking_at("{% end")