future-boots-43048
12/12/2020, 3:17 PMmysterious-toddler-20573
12/12/2020, 3:17 PMmysterious-toddler-20573
12/12/2020, 3:18 PMhtmx:sse:<eventName>mysterious-toddler-20573
12/12/2020, 3:18 PMfuture-boots-43048
12/12/2020, 3:18 PMmysterious-toddler-20573
12/12/2020, 3:18 PMfuture-boots-43048
12/12/2020, 3:19 PMfuture-boots-43048
12/12/2020, 3:19 PMfuture-boots-43048
12/12/2020, 3:19 PMfuture-boots-43048
12/12/2020, 3:19 PMfuture-boots-43048
12/12/2020, 3:20 PMfuture-boots-43048
12/12/2020, 3:20 PMfuture-boots-43048
12/12/2020, 3:21 PMfuture-boots-43048
12/12/2020, 3:21 PMfuture-boots-43048
12/12/2020, 3:22 PMlively-beach-14291
12/12/2020, 3:22 PMlively-beach-14291
12/12/2020, 3:24 PMcamelCase to kebab-case, however, this doesn't work for SVG attributes. This means I'd have to scan the content to grok namespace and then make serialization of attribute names be based upon namespace. My colleague Kyrylo suggested that I should be stupider. camelCase stays camelCase but snake_case becomes kebab-case. So, people using HTML would have to write hx_swap in Julia and not hxSwap.lively-beach-14291
12/12/2020, 3:27 PMfuture-boots-43048
12/12/2020, 3:28 PMmysterious-toddler-20573
12/12/2020, 3:28 PMlively-beach-14291
12/12/2020, 3:28 PMfuture-boots-43048
12/12/2020, 3:28 PMfuture-boots-43048
12/12/2020, 3:30 PM@staticmethod
def clean_attribute(attribute):
'''
Normalize attribute names for shorthand and work arounds for limitations
in Python's syntax
'''
# Shorthand
attribute = {
'cls': 'class',
'className': 'class',
'class_name': 'class',
'fr': 'for',
'html_for': 'for',
'htmlFor': 'for',
}.get(attribute, attribute)
# Workaround for Python's reserved words
if attribute[0] == '_':
attribute = attribute[1:]
# Workaround for dash
special_prefix = any([attribute.startswith(x) for x in ('data_', 'aria_')])
if attribute in set(['http_equiv']) or special_prefix:
attribute = attribute.replace('_', '-').lower()
# Workaround for colon
if attribute.split('_')[0] in ('xlink', 'xml', 'xmlns'):
attribute = attribute.replace('_', ':', 1).lower()
return attributefuture-boots-43048
12/12/2020, 3:30 PMfuture-boots-43048
12/12/2020, 3:30 PMmysterious-toddler-20573
12/12/2020, 3:33 PMmysterious-toddler-20573
12/12/2020, 3:33 PMfuture-boots-43048
12/12/2020, 3:37 PMfuture-boots-43048
12/12/2020, 3:37 PMmysterious-toddler-20573
12/12/2020, 3:39 PM