--- a/ztfy/utils/tal/html.py Sat Apr 10 16:31:08 2010 +0200
+++ b/ztfy/utils/tal/html.py Sat Apr 17 02:16:51 2010 +0200
@@ -28,7 +28,7 @@
# import local packages
from ztfy.utils.html import htmlToText
-from ztfy.utils.text import textToHTML
+from ztfy.utils.text import textToHTML, Renderer
class HTMLTalesAdapter(object):
@@ -41,6 +41,9 @@
def setEngine(self, engine):
self.request = engine.vars['request']
+ def renderer(self):
+ return Renderer(self.context)
+
def totext(self):
if not self.context:
return u''
--- a/ztfy/utils/tal/interfaces.py Sat Apr 10 16:31:08 2010 +0200
+++ b/ztfy/utils/tal/interfaces.py Sat Apr 17 02:16:51 2010 +0200
@@ -50,6 +50,9 @@
class IHTMLTalesAPI(Interface):
"""'html' TALES namespace interface"""
+ def renderer():
+ """Get text to HTML renderer"""
+
def totext():
"""Convert adapted HTML content to text"""
--- a/ztfy/utils/text.py Sat Apr 10 16:31:08 2010 +0200
+++ b/ztfy/utils/text.py Sat Apr 17 02:16:51 2010 +0200
@@ -56,3 +56,14 @@
formatter = createObject(renderer, text)
renderer = zapi.queryMultiAdapter((formatter, request), name=u'')
return renderer.render()
+
+
+class Renderer(object):
+
+ def __init__(self, context):
+ self.context = context
+
+ def render(self, renderer, request=None):
+ if not self.context:
+ return u''
+ return textToHTML(self.context, renderer, request)