Zulip server and web application. Open-source team chat that helps teams stay productive and focused.
template_parser: Spell “Handlebars” correctly.
Anders Kaseorg8da2eb58ec34
diff --git a/tools/check-templates b/tools/check-templatesindex 68a0ec7e67c..41c36332424 100755--- a/tools/check-templates+++ b/tools/check-templates@@ -42,7 +42,7 @@ def check_our_files(modified_only: bool, all_dups: bool, fix: bool, targets: Lisexclude=EXCLUDED_FILES,)- check_handlebar_templates(by_lang["hbs"], fix)+ check_handlebars_templates(by_lang["hbs"], fix)check_html_templates(by_lang["html"], all_dups, fix)@@ -108,8 +108,8 @@ def check_html_templates(templates: Iterable[str], all_dups: bool, fix: bool) ->sys.exit(1)-def check_handlebar_templates(templates: Iterable[str], fix: bool) -> None:- # Check all our handlebars templates.+def check_handlebars_templates(templates: Iterable[str], fix: bool) -> None:+ # Check all our Handlebars templates.templates = [fn for fn in templates if fn.endswith(".hbs")]for fn in templates:diff --git a/tools/lib/pretty_print.py b/tools/lib/pretty_print.pyindex 1691248cb69..3166ccc443e 100644--- a/tools/lib/pretty_print.py+++ b/tools/lib/pretty_print.py@@ -111,7 +111,7 @@ def fix_indents_for_multi_line_tags(tokens: List[Token]) -> None:if token.line_span == 1 or token.indent is None:continue- if token.kind in ("django_comment", "handlebar_comment", "html_comment", "text"):+ if token.kind in ("django_comment", "handlebars_comment", "html_comment", "text"):continue_indent = token.indentelse:continue_indent = token.indent + " "diff --git a/tools/lib/template_parser.py b/tools/lib/template_parser.pyindex 76655aa33bd..1bd78e48a84 100644--- a/tools/lib/template_parser.py+++ b/tools/lib/template_parser.py@@ -66,13 +66,13 @@ def tokenize(text: str) -> List[Token]:def looking_at_htmlcomment() -> bool:return looking_at("<!--")- def looking_at_handlebarcomment() -> bool:+ def looking_at_handlebars_comment() -> bool:return looking_at("{{!")def looking_at_djangocomment() -> bool:return looking_at("{#")- def looking_at_handlebarpartial() -> bool:+ def looking_at_handlebars_partial() -> bool:return looking_at("{{>")def looking_at_html_start() -> bool:@@ -128,16 +128,16 @@ def tokenize(text: str) -> List[Token]:s = get_html_comment(text, state.i)tag = s[4:-3]kind = "html_comment"- elif looking_at_handlebarcomment():- s = get_handlebar_comment(text, state.i)+ elif looking_at_handlebars_comment():+ s = get_handlebars_comment(text, state.i)tag = s[3:-2]- kind = "handlebar_comment"+ kind = "handlebars_comment"elif looking_at_djangocomment():s = get_django_comment(text, state.i)tag = s[2:-2]kind = "django_comment"- elif looking_at_handlebarpartial():- s = get_handlebar_partial(text, state.i)+ elif looking_at_handlebars_partial():+ s = get_handlebars_partial(text, state.i)tag = s[9:-2]kind = "handlebars_singleton"elif looking_at_html_start():@@ -298,7 +298,7 @@ def tag_flavor(token: Token) -> Optional[str]:if kind in ("code","django_comment",- "handlebar_comment",+ "handlebars_comment","handlebars_singleton","html_comment","html_doctype",@@ -687,7 +687,7 @@ def get_html_comment(text: str, i: int) -> str:raise TokenizationException("Unclosed comment", text[i:unclosed_end])-def get_handlebar_comment(text: str, i: int) -> str:+def get_handlebars_comment(text: str, i: int) -> str:end = i + 5unclosed_end = 0while end <= len(text):@@ -725,7 +725,7 @@ def get_django_comment(text: str, i: int) -> str:raise TokenizationException("Unclosed comment", text[i:unclosed_end])-def get_handlebar_partial(text: str, i: int) -> str:+def get_handlebars_partial(text: str, i: int) -> str:end = i + 10unclosed_end = 0while end <= len(text):