[ZPT] Built-in STX and TAL wrappers proposal

Trevor Toenjes zope at toenjes.com
Tue May 27 11:42:28 EDT 2003


Dieter,
Thanks for the reply.

Now I have to ask the general question for some ZPT expert advise...
is there any reason that ZPT should not include a STX and TAL wrapper to
complement the existing 'structure' HTML wrapper?

As I look at using an external method to accomplish what I think should be
part of ZPT...I am wondering why a page_template wouldn't be allowed to
render a string with TAL or STX?  This seems like a natural use of
properties in a page template.  STX is already part of the Zope API.

Since structure exists:
tal:content="structure here/some_HTML"

My proposal is to add STX and TAL wrappers to be used like...
tal:content="STX here/some_structured_text"
tal:content="TAL here/some_HTML_with_TAL"

So...Is there anything wrong with this concept?

-Trevor

> -----Original Message-----
> From: Dieter Maurer [mailto:dieter at handshake.de]
> Sent: Thursday, May 22, 2003 2:40 PM
> To: Trevor Toenjes
> Cc: Zpt at Zope. Org
> Subject: Re: [ZPT] How can you use TAL to render a textarea property?
>
>
> 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