Nikko Wolf wrote:
Ian Bicking wrote:

I'm surprised this has never come up for me before, but now I want to render a recursive data structure and I'm at a loss how I might do that in ZPT. Or, what the best workaround would be. E.g.:

['a', 'b', ['c', ['d', 'e']]]



I've made recursive macros before. It's not so different from other recursion techniques. Here's one to render a site tree::

     <title tal:content="template/title">The title</title>
     Site structure:

   <tal:contain define="location nocall:here">
    <div metal:use-macro="template/macros/list" />


 <tal:hidemacro replace="nothing">
 <metal:recurse define-macro="list">
     <li tal:repeat="elt location/objectValues">
       <span tal:content="elt/getId">objectId</span>
       <metal:block tal:condition="elt/isPrincipiaFolderish"
                    tal:define="location nocall:elt">
           <div metal:use-macro="template/macros/list" />

It will go from 'context', of course, unless you were to change the definition of 'location' in the page.

You can imagine how this would work with a nested list: you just have to have ways of checking containership and getting contents.


"Building Websites with Plone"

Enfold Systems, LLC
Zope maillist  -
**   No cross posts or HTML encoding!  **
(Related lists - )

Reply via email to