--- a/src/pyams_utils/text.py Wed Jul 04 09:05:30 2018 +0200
+++ b/src/pyams_utils/text.py Fri Jul 06 09:47:39 2018 +0200
@@ -152,3 +152,18 @@
terms = [SimpleTerm(name, name, translate(adapt.title).label)
for name, adapt in registry.getAdapters(('', request), IHTMLRenderer)]
super(RenderersVocabulary, self).__init__(terms)
+
+
+@adapter_config(name='br', context=(Interface, Interface, Interface), provides=ITALESExtension)
+class BrTalesExtension(ContextRequestViewAdapter):
+ """extension:br(value, class) TALES expression
+
+ This expression can be used to context a given character ('|' by default) into HTML
+ breaks with given CSS class.
+ """
+
+ def render(self, context=None, css_class='', character='|'):
+ if context is None:
+ context = self.context
+ br = '<br {0} />'.format('class="{0}"'.format(css_class) if css_class else '')
+ return context.replace(character, br)