One of the commonest operations is to attach a
class attribute to an XML tag. For instance,
suppose you want to generate this content:
<div class='warning'> Your brain may not be the boss! </div>
The obvious way to do this does not work:
E.div("Your brain may not be the boss!", class='warning') # Fails!
class is a reserved word in Python, you
can't use it as an argument keyword. Therefore, the package
includes a helper function named
takes one or more names as arguments, and returns a dictionary
that can be passed to the
to add a
class= attribute with the argument
value. This example does work to generate the above XML:
E.div("Your brain may not be the boss!", CLASS('warning')) # Works.
Here's another example, this time with multiple class names.
E.span(CLASS('ref', 'index'), "Pie, whole.")
<span class='ref index'>Pie, whole.</span>