common/uilib.py
changeset 2516 b58826130680
parent 2458 4d114865098f
child 2808 497424219fb0
child 2933 d511ddcd2689
child 2996 866a2c135c33
--- a/common/uilib.py	Mon Jul 27 18:36:30 2009 +0200
+++ b/common/uilib.py	Mon Jul 27 18:36:51 2009 +0200
@@ -212,6 +212,11 @@
 HTML4_EMPTY_TAGS = frozenset(('base', 'meta', 'link', 'hr', 'br', 'param',
                               'img', 'area', 'input', 'col'))
 
+def sgml_attributes(attrs):
+    return u' '.join(u'%s="%s"' % (attr, xml_escape(unicode(value)))
+                     for attr, value in sorted(attrs.items())
+                     if value is not None)
+
 def simple_sgml_tag(tag, content=None, escapecontent=True, **attrs):
     """generation of a simple sgml tag (eg without children tags) easier
 
@@ -223,9 +228,7 @@
             attrs['class'] = attrs.pop('klass')
         except KeyError:
             pass
-        value += u' ' + u' '.join(u'%s="%s"' % (attr, xml_escape(unicode(value)))
-                                  for attr, value in sorted(attrs.items())
-                                  if value is not None)
+        value += u' ' + sgml_attributes(attrs)
     if content:
         if escapecontent:
             content = xml_escape(unicode(content))