| Home | Trees | Indices | Help |
|
|---|
|
|
object --+
|
Directive --+
|
AttrsDirective
Implementation of the py:attrs template directive.
The value of the py:attrs attribute should be a dictionary or a sequence of (name, value) tuples. The items in that dictionary or sequence are added as attributes to the element:
>>> from genshi.template import MarkupTemplate >>> tmpl = MarkupTemplate('''<ul xmlns:py="http://genshi.edgewall.org/"> ... <li py:attrs="foo">Bar</li> ... </ul>''') >>> print(tmpl.generate(foo={'class': 'collapse'})) <ul> <li class="collapse">Bar</li> </ul> >>> print(tmpl.generate(foo=[('class', 'collapse')])) <ul> <li class="collapse">Bar</li> </ul>
If the value evaluates to None (or any other non-truth value), no attributes are added:
>>> print(tmpl.generate(foo=None)) <ul> <li>Bar</li> </ul>
| Nested Classes | |
|
Inherited from |
| Instance Methods | |||
|
|||
|
Inherited from Inherited from |
|||
| Class Methods | |
|
Inherited from |
| Class Variables | |
tagname =
|
|
| Properties | |
|
Inherited from Inherited from |
| Method Details |
|
| Home | Trees | Indices | Help |
|
|---|
| Generated by Epydoc 3.0.1 on Thu Apr 22 14:10:37 2010 | http://epydoc.sourceforge.net |