Knio / dominate

Dominate is a Python library for creating and manipulating HTML documents using an elegant DOM API. It allows you to write HTML pages in pure Python very concisely, which eliminate the need to learn another template language, and to take advantage of the more powerful features of Python.
GNU Lesser General Public License v3.0
1.72k stars 108 forks source link

Enable attributes without values #165

Closed baloe closed 2 years ago

baloe commented 2 years ago

It seems acceptable to also have attributes without values, e.g. the controls attribute for the video tag: https://www.w3schools.com/html/html5_video.asp

<video controls> ...

Is this possible with dominate? If so I am unable to figure out how. If not, how about adding a rule that attribute=None is rendered as an attribute without a value? Right now attribute=None seems to be equivalent to attribute=False which simply prevents the attribute from being rendered at all.

golightlyb commented 2 years ago

Note that

<video controls>

is equivalent to

<video controls="controls">
Knio commented 2 years ago

Other users had requested that attribute=None means it should be interpreted the same as not present at all (same as deleted). See previous issues.

As above, attribute=True results in rendering as attribute="attribute", and the HTML spec enforces that to mean the same thing a present with no value.