[Zope] DTML Container?
Alexandre Ratti
alex@gabuzomeu.net
Thu, 10 Feb 2000 11:53:38 +0100
Hello,
I think you can also render the body with: <dtml-var "_.render(this())">.
I know this looks kludgy, but it worked for me and you don't need to handle
an external method. I included below a mail I sent when I came across this
solution.
Cheers.
Alexandre
At 12:00 08/02/2000 -0800, you wrote:
>Look at Kevin Dangoor's KM|NetNews Product for a nice take on this. The
>outline
>of the solution is to define a method 'index_html' within your ZClass (not
>inside each instance!). This method "stitches together" the properties of the
>object to present its "default view".
>
>The key problem is to get the "body" property to be rendered using the DTML
>engine, but filled out using the properties of the main object. Here is a
>Python ExternalMethod (add it to the ZClass) which does the trick::
>
> from DocumentTemplate import HTML
>
> def render_dtml( self, string_property ):
> """
> """
> return HTML( string_property, self.__dict__ )()
>
>You can then use this within the ZClass' instance_html as:
>
> <dtml-var "render_dtml( body )">
[Archive email dated December 1999]
>I eventually found a solution for the problem described below.
>
>Summary: I have a ZClass that subclasses DTMLDocument. In the ZClass
>product folder, I have an index_html method that provides a default view
>for ZClass instances. I want this method to display both property values
>and the text content of the ZClass instance.
>
>To display the text content, if I use <dtml-var raw>, the text is
>displayed in unrendered form. Text and HTML code are OK but nested DTML is
>not interpreted. To display the text content in rendered form, I need to
>use <dtml-var "_.render(this())">.
>
>Example code for index_html:
>
><dtml-var standard_html_header>
> <H2 align="center"><dtml-var title_or_id></H2>
>
><P><EM><dtml-var myDateProperty></EM><BR>
><dtml-var myDescriptionProperty></P>
>
> <dtml-var "_.render(this())">
><dtml-var standard_html_footer>