Let make_attributes replace underscores with hyphens in attr names.
This commit is contained in:
parent
705bd8269f
commit
78a3aa36a8
1 changed files with 5 additions and 1 deletions
|
@ -68,7 +68,11 @@ def users_to_usernames(users):
|
||||||
|
|
||||||
@global_function
|
@global_function
|
||||||
def make_attributes(*booleans, **keyvalues):
|
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 = [f'{key}="{jinja2.filters.escape(value)}"' for (key, value) in keyvalues.items()]
|
||||||
attributes.extend(booleans)
|
attributes.extend(booleans)
|
||||||
attributes = ' '.join(attributes)
|
attributes = ' '.join(attributes)
|
||||||
|
|
Loading…
Reference in a new issue