check_templates: Parse '<foo/>' tags better.

If folks put something like '<br/>' in the HTML,
we would think the tag's name was "br/" instead
of "br".  I think we were assuming most folks
would write either "<br>" or <br />".

ASIDE:

We should probably have a consistent
preference among these styles:

    * <br>
    * <br/>
    * <br />

I prefer the first.
This commit is contained in:
Steve Howell
2020-04-19 11:08:35 +00:00
parent ca7c79c93e
commit 28f2a6950e

View File

@@ -103,7 +103,11 @@ def tokenize(text: str) -> List[Token]:
kind = 'handlebars_singleton'
elif looking_at_html_start():
s = get_html_tag(text, state.i)
tag_parts = s[1:-1].split()
if s.endswith('/>'):
end_offset = -2
else:
end_offset = -1
tag_parts = s[1:end_offset].split()
if not tag_parts:
raise TemplateParserException("Tag name missing")