changeset 205:b700e5326421 trunk

Add doctest to verify that the `py:attrs` directive correctly handles a sequence of `(name, value)` tuples.
author cmlenz
date Sat, 26 Aug 2006 00:17:03 +0000
parents 51d4101f49ca
children 75c9c019de88
files markup/template.py
diffstat 1 files changed, 7 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/markup/template.py
+++ b/markup/template.py
@@ -194,8 +194,9 @@
 class AttrsDirective(Directive):
     """Implementation of the `py:attrs` template directive.
     
-    The value of the `py:attrs` attribute should be a dictionary. The keys and
-    values of that dictionary will be added as attributes to the element:
+    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:
     
     >>> tmpl = Template('''<ul xmlns:py="http://markup.edgewall.org/">
     ...   <li py:attrs="foo">Bar</li>
@@ -204,6 +205,10 @@
     <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:
Copyright (C) 2012-2017 Edgewall Software