--- a/src/pyams_utils/text.py Mon Sep 17 16:14:22 2018 +0200
+++ b/src/pyams_utils/text.py Mon Sep 17 17:38:43 2018 +0200
@@ -81,6 +81,17 @@
return html.escape(self.context).replace('\n', '<br />\n')
+@adapter_config(name='js', context=(str, IRequest), provides=IHTMLRenderer)
+class JsRenderer(BaseHTMLRenderer):
+ """Custom Javascript HTML renderer
+
+ This renderer replaces single quotes with escaped ones
+ """
+
+ def render(self, **kwargs):
+ return self.context.replace("'", "\\'")
+
+
@adapter_config(name='rest', context=(str, IRequest), provides=IHTMLRenderer)
class ReStructuredTextRenderer(BaseHTMLRenderer):
"""reStructuredText HTML renderer