hummm tls-sprint
authorsylvain.thenault@logilab.fr
Thu, 30 Apr 2009 18:11:42 +0200
branchtls-sprint
changeset 1623 0b974e21d762
parent 1622 1a1c494b88e2
child 1624 baf484a182cd
hummm
common/tags.py
common/uilib.py
--- a/common/tags.py	Thu Apr 30 17:36:33 2009 +0200
+++ b/common/tags.py	Thu Apr 30 18:11:42 2009 +0200
@@ -9,17 +9,19 @@
 from cubicweb.common.uilib import simple_sgml_tag
 
 class tag(object):
-    def __init__(self, name):
+    def __init__(self, name, escapecontent=True):
         self.name = name
-        
+        self.escapecontent = escapecontent
+
     def __call__(self, __content=None, **attrs):
+        attrs.setdefault('escapecontent', self.escapecontent)
         return simple_sgml_tag(self.name, __content, **attrs)
 
 input = tag('input')
 textarea = tag('textarea')
 a = tag('a')
 span = tag('span')
-div = tag('div')
+div = tag('div', False)
 img = tag('img')
 label = tag('label')
 option = tag('option')
--- a/common/uilib.py	Thu Apr 30 17:36:33 2009 +0200
+++ b/common/uilib.py	Thu Apr 30 18:11:42 2009 +0200
@@ -204,7 +204,7 @@
 
 # HTML generation helper functions ############################################
 
-def simple_sgml_tag(tag, content=None, **attrs):
+def simple_sgml_tag(tag, content=None, escapecontent=True, **attrs):
     """generation of a simple sgml tag (eg without children tags) easier
 
     content and attributes will be escaped
@@ -219,7 +219,9 @@
                                   for attr, value in attrs.items()
                                   if value is not None)
     if content:
-        value += u'>%s</%s>' % (html_escape(unicode(content)), tag)
+        if escapecontent:
+            content = html_escape(unicode(content))
+        value += u'>%s</%s>' % (content, tag)
     else:
         value += u'/>'
     return value