Updated 'br' TALES extension
authorThierry Florac <thierry.florac@onf.fr>
Fri, 21 Sep 2018 10:33:05 +0200
changeset 233 3ba5d4160566
parent 232 5dad602b4ca9
child 234 30d866448bfd
Updated 'br' TALES extension
src/pyams_utils/text.py
--- a/src/pyams_utils/text.py	Fri Sep 21 10:21:52 2018 +0200
+++ b/src/pyams_utils/text.py	Fri Sep 21 10:33:05 2018 +0200
@@ -178,12 +178,9 @@
         if not value:
             return ''
         br = '<br {0} />'.format('class="{0}"'.format(css_class) if css_class else '')
-        if start_tag or end_tag:
-            elements = value.split(character)
-            if start_tag:
-                elements[0] = '<{0}>{1}</{0}>'.format(start_tag, elements[0])
-            if end_tag:
-                elements[-1] = '<{0}>{1}</{0}>'.format(end_tag, elements[-1])
-            return br.join(elements)
-        else:
-            return value.replace(character, br)
+        elements = value.split(character)
+        if start_tag:
+            elements[0] = '<{0}>{1}</{0}>'.format(start_tag, elements[0])
+        if end_tag:
+            elements[-1] = '<{0}>{1}</{0}>'.format(end_tag, elements[-1])
+        return br.join(elements)