Let make_attributes replace underscores with hyphens in attr names.

This commit is contained in:
voussoir 2020-09-27 12:14:20 -07:00
parent 705bd8269f
commit 78a3aa36a8

View file

@ -68,7 +68,11 @@ def users_to_usernames(users):
@global_function
def make_attributes(*booleans, **keyvalues):
keyvalues = {key: value for (key, value) in keyvalues.items() if value is not None}
keyvalues = {
key.replace('_', '-'): value
for (key, value) in keyvalues.items()
if value is not None
}
attributes = [f'{key}="{jinja2.filters.escape(value)}"' for (key, value) in keyvalues.items()]
attributes.extend(booleans)
attributes = ' '.join(attributes)