[Mpuls-commits] r1724 - in wasko/branches/2.0: . mpulsweb/lib

scm-commit@wald.intevation.org scm-commit at wald.intevation.org
Wed Feb 24 11:01:18 CET 2010


Author: bh
Date: 2010-02-24 11:01:15 +0100 (Wed, 24 Feb 2010)
New Revision: 1724

Modified:
   wasko/branches/2.0/ChangeLog
   wasko/branches/2.0/mpulsweb/lib/renderer.py
Log:
* mpulsweb/lib/renderer.py (tag): Add doc-string.


Modified: wasko/branches/2.0/ChangeLog
===================================================================
--- wasko/branches/2.0/ChangeLog	2010-02-23 20:10:15 UTC (rev 1723)
+++ wasko/branches/2.0/ChangeLog	2010-02-24 10:01:15 UTC (rev 1724)
@@ -1,3 +1,7 @@
+2010-02-24  Bernhard Herzog  <bh at intevation.de>
+
+	* mpulsweb/lib/renderer.py (tag): Add doc-string.
+
 2010-02-23  Bernhard Herzog  <bh at intevation.de>
 
 	Make the renderer quote texts properly:

Modified: wasko/branches/2.0/mpulsweb/lib/renderer.py
===================================================================
--- wasko/branches/2.0/mpulsweb/lib/renderer.py	2010-02-23 20:10:15 UTC (rev 1723)
+++ wasko/branches/2.0/mpulsweb/lib/renderer.py	2010-02-24 10:01:15 UTC (rev 1724)
@@ -70,6 +70,26 @@
 
 
 def tag(tagname, _close=False, **attrs):
+    """Create an opening HTML tag with properly escaped attributes.
+
+    The tagname parameter gives the name of the tag.  The attributes are
+    given as keyword parameters.  The attribute value should be either
+    strings (byte-strings or unicode) in which case they will be
+    properly escaped.  The values may also be booleans, in which case
+    the attribute is included in the tag with only its name if the value
+    is true and completely omitted otherwise.
+
+    To allow for attribute names that are also python keywords, a single
+    trailing underscore character is removed from an attribute name if
+    it is preset, so that e.g. the class attribute can be specified
+    using the class_ keyword parameters.
+
+    Examples:
+    >>> from mpulsweb.lib.renderer import tag
+    >>> tag("input", type="text", name="title", disabled=False)
+    '<input type="text" name="title">'
+    >>> 
+    """
     out = ["<%s" % tagname]
     for name, value in attrs.items():
         if name.endswith("_"):



More information about the Mpuls-commits mailing list