[ZPT] How can you use TAL to render a textarea property?

Dieter Maurer dieter at handshake.de
Thu May 22 21:39:50 EDT 2003


Trevor Toenjes wrote at 2003-5-21 16:48 -0400:
 > How can I render a property textarea (whether in a ZPT or a Folder) using
 > TAL?
 > 
 > IOW...
 > I want to be able to use properties to hold TAL'd content and render it just
 > like I would Structured Text or plain text.
 > 
 > example:
 > <div tal:define="pss modules/Products.PythonScripts.standard">
 > <span tal:condition="python:here.content_html.editmode=='stx'"
 >       tal:replace="structure
 > python:pss.structured_text(here.content_html.page_copy)">page copy content
 > here rendered in STX</span>
 > </div>
 > 
 > How can I do this with ZPT/TAL?

I did not understand what you wanted....
Fortunately, Chris did :-)

There is no (easy) build-in way to render strings as TAL templates.
You must create a template, wrap it and then render it.
This is possible only in an External Method or other external
Python code.

It will look somehow like:

   from Products.PageTemplates.ZopePageTemplate import ZopePageTemplate

   template= ZopePageTemplate('',your_template_string,'text/html')
   # now wrap it into a context
   wrappedTemplate= template.__of__(context)
   # render it
   renderResult= wrappedTemplate()


Dieter



More information about the ZPT mailing list