Closed Aladio closed 4 years ago
Try using dictionary unpacking to get around having a hyphen in the keyword:
with doc.head:
meta(**{'content': 'text/html;charset=utf-8', 'http-equiv': 'Content-Type'})
meta(**{'content': 'utf-8', 'http-equiv': 'encoding'})
print(doc)
Output
<!DOCTYPE html>
<html>
<head>
<title>Dominate your HTML</title>
<meta content="text/html;charset=utf-8" http-equiv="Content-Type">
<meta content="utf-8" http-equiv="encoding">
</head>
<body></body>
</html>
meta(content='utf-8', **{'http-equiv': 'encoding'})
is also valid.
Thank you!!
------ Original Message ------ From: "Lachlan Kidson" notifications@github.com To: "Knio/dominate" dominate@noreply.github.com Cc: "Aladio" faladio@yahoo.com; "Author" author@noreply.github.com Sent: 10/15/2019 8:53:11 AM Subject: Re: [Knio/dominate] meta tag issues (#116)
Try using dictionary unpacking https://docs.python.org/3.7/tutorial/controlflow.html#unpacking-argument-lists to get around having a hyphen in the keyword:
with doc.head: meta({'content': 'text/html;charset=utf-8', 'http-equiv': 'Content-Type'}) meta({'content': 'utf-8', 'http-equiv': 'encoding'})
print(doc)
Output
<!DOCTYPE html>
Dominate your HTML — You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/Knio/dominate/issues/116?email_source=notifications&email_token=AAYKVBOMMNQ5ZBNG4GGYXUTQOXKNPA5CNFSM4I5YVVKKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEBJB75A#issuecomment-542253044, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAYKVBLTMNTFEIZTWANER43QOXKNPANCNFSM4I5YVVKA.
This is special-cased so you can use an underscore: http_equiv
:
from dominate.tags import meta
expected = '<meta content="text/html;charset=utf-8" http-equiv="Content-Type">'
assert meta(content="text/html;charset=utf-8", http_equiv="Content-Type").render() == expected
meta tag issues
input with doc.head: meta('content="text/html;charset=utf-8", http-equiv="Content-Type"') meta('content="utf-8", http-equiv="encoding"') output <meta> <meta>
input with doc.head: meta(raw('content="text/html;charset=utf-8" http-equiv="Content-Type"')) meta(raw('content="utf-8" http-equiv="encoding"')) output <meta> <meta>