"0 in [True,False]" returns True

Duncan Booth duncan.booth at invalid.invalid
Tue Dec 13 05:40:21 EST 2005


 wrote:

> For HTML attributes that don't have an explicit value (such as the
> SELECTED attribute in OPTION) the keyword argument to the function must
> have the value True
> 

A better way to do this (given that HTML defines exactly which attributes 
do not take a value) is to use the attribute name and simply generate the 
attribute only if the value is non-false.

>From Zope's TAL parser:

BOOLEAN_HTML_ATTRS = [
    # List of Boolean attributes in HTML that may be given in
    # minimized form (e.g. <img ismap> rather than <img ismap="">)
    # From http://www.w3.org/TR/xhtml1/#guidelines (C.10)
    "compact", "nowrap", "ismap", "declare", "noshade", "checked",
    "disabled", "readonly", "multiple", "selected", "noresize",
    "defer"
    ]

EMPTY_HTML_TAGS = [
    # List of HTML tags with an empty content model; these are
    # rendered in minimized form, e.g. <img />.
    # From http://www.w3.org/TR/xhtml1/#dtds
    "base", "meta", "link", "hr", "br", "param", "img", "area",
    "input", "col", "basefont", "isindex", "frame",
    ]



More information about the Python-list mailing list