Meloun Meloun - 1 month ago 9
HTML Question

python html generator

I am looking for an easily implemented html generator for python. I found this one

http://www.decalage.info/python/html


but there is no way to add css elements (id, class) for table.

thx

Answer

If you want programmatic generation rather than templating, Karrigell's HTMLTags module is one possibility; it can include e.g. the class attribute (which would be a reserved word in Python) by the trick of uppercasing its initial, i.e., quoting the doc URL I just gave:

Attributes with the same name as Python keywords (class, type) must be capitalized :

print DIV('bar', Class="title")  ==>  <DIV class="title">bar</DIV>
Comments