mirror of https://github.com/zulip/zulip.git
template_parser: Spell “Handlebars” correctly.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
This commit is contained in:
parent
7d485aa58f
commit
8da2eb58ec
|
@ -42,7 +42,7 @@ def check_our_files(modified_only: bool, all_dups: bool, fix: bool, targets: Lis
|
|||
exclude=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:
|
||||
|
|
|
@ -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.indent
|
||||
else:
|
||||
continue_indent = token.indent + " "
|
||||
|
|
|
@ -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 + 5
|
||||
unclosed_end = 0
|
||||
while 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 + 10
|
||||
unclosed_end = 0
|
||||
while end <= len(text):
|
||||
|
|
Loading…
Reference in New Issue