- I posted a 70-line recipe on the Python Cookbook, a sort of poor man's HTMLGen called HTMLTags
http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/366000
with a syntax like this :
# print HTML( HEAD(TITLE('Test document')) + # BODY(H1('This is a test document')+ # TEXT('First line')+BR()+ # TEXT('Second line')))
The use of addition allows for shortcuts like print Sum([ TR(TD(i)+TD(i*i)) for i in range(100) ])
where Sum works like the built-in sum, but sum only works for numbers apparently
- in the Cookbook someone mentioned the HyperText package, published in 2000 by Andy Dustman : http://dustman.net/andy/python/HyperText/
It uses this syntax :
# print TABLE( # TR((TH('SPAM'), TH('EGGS')), # TR(TD('foo','bar', colspan=2)) # )
The package also handles XML, SGML etc.
- I wrote to Andy and he said there was also Living Logic's XIST : http://www.livinglogic.de/Python/xist/index.html
An example taken from the site :
#node = xsc.Frag( # xml.XML10(), # html.DocTypeXHTML10transitional(), # html.html( # html.head( # meta.contenttype(), # html.title("Example page") # ), # html.body( # html.h1("Welcome to the example page"), # html.p( # "This example page has a link to the ", # html.a("Python home page", href="http://www.python.org/"), # "." # ) # ) # ) # ) # # print node.conv().asBytes(encoding="us-ascii") -- http://mail.python.org/mailman/listinfo/python-list