web/views/primary.py
changeset 7846 dd3f0871d8b7
parent 7845 2172978be237
child 7848 db6bb2da397c
--- a/web/views/primary.py	Fri Sep 23 14:18:13 2011 +0200
+++ b/web/views/primary.py	Fri Sep 23 14:43:44 2011 +0200
@@ -34,6 +34,7 @@
 
 .. autoclass:: AttributeView
 .. autoclass:: URLAttributeView
+.. autoclass:: VerbatimAttributeView
 """
 
 __docformat__ = "restructuredtext en"
@@ -421,20 +422,6 @@
                 self.w(u'</div>')
 
 
-class URLAttributeView(EntityView):
-    """:__regid__: *urlattr*
-
-    This view will wrap an attribute value (hence expect a string) into an '<a>'
-    HTML tag to display a clickable link.
-    """
-    __regid__ = 'urlattr'
-    __select__ = EntityView.__select__ & match_kwargs('rtype')
-
-    def entity_call(self, entity, rtype, **kwargs):
-        url = entity.printable_value(rtype)
-        if url:
-            self.w(u'<a href="%s">%s</a>' % (url, url))
-
 class AttributeView(EntityView):
     """:__regid__: *attribute*
 
@@ -455,6 +442,39 @@
                 self.wview('autolimited', rset, initargs={'dispctrl': dispctrl})
 
 
+class URLAttributeView(EntityView):
+    """:__regid__: *urlattr*
+
+    This view will wrap an attribute value (hence expect a string) into an '<a>'
+    HTML tag to display a clickable link.
+    """
+    __regid__ = 'urlattr'
+    __select__ = EntityView.__select__ & match_kwargs('rtype')
+
+    def entity_call(self, entity, rtype, **kwargs):
+        url = entity.printable_value(rtype)
+        if url:
+            self.w(u'<a href="%s">%s</a>' % (url, url))
+
+
+class VerbatimAttributeView(EntityView):
+    """:__regid__: *verbatimattr*
+
+    This view will wrap an attribute value into an '<pre>' HTML tag to display
+    arbitrary text where EOL will be respected. It usually make sense for
+    attributes whose value is a multi-lines string where new lines matters.
+    """
+    __regid__ = 'verbatimattr'
+    __select__ = EntityView.__select__ & match_kwargs('rtype')
+
+    def entity_call(self, entity, rtype, **kwargs):
+        value = entity.printable_value(rtype)
+        if value:
+            self.w(u'<pre>%s</pre>' % value)
+
+
+
+
 
 class ToolbarLayout(component.Layout):
     # XXX include me in the doc