galvez/xmlwitch — pull request #10 by jleverenz (2013-07-27 11:19:26+00:00)
Title: Support for empty elements without None param

This change allows both "old style" empty elements, which required a place holder paramater

xml.img(None, src="http://server/image.jpg")

and "new style", which does not:

xml.img(src="http://server/image.jpg")

Also, whether to render a close tag in __call__ depends on whether this is used in a with context. To handle this, Builder is reworked to build & modify a tree data structure until __str__ is called, at which point the data structure is rendered to text with complete knowledge of the tree.

i.e. the following used to fail, rendering the div twice. Support for the "new style" made this even more exposed:

with xml.div(None, id="name"):
xml.p("hi")