Zope (ZPT) overlapping tags <p>I try to create an open <code>div</code> tag condition and close a <code>div</code> tag in another condition with TAL in a Zope Page Template but I'm not allowed to overlap tags.</p> <p>Here is my code :</p> <pre><code>&lt;div id="notaccordion"&gt; &lt;tal:x repeat="item python:range(26)"&gt; &lt;tal:x define="global block_name python:current.values()[0]['block_name']"&gt; &lt;tal:x condition="python:isDone"&gt; &lt;/div&gt; &lt;/tal:x&gt; &lt;tal:x condition="python:not isDone"&gt; &lt;tal:x replace="python:block_name"&gt; &lt;/tal:x&gt; &lt;div&gt; &lt;/tal:x&gt; &lt;/tal:x&gt; &lt;/tal:x&gt; &lt;/div&gt; </code></pre> <p>The important part is:</p> <pre><code> &lt;tal:x condition="python:isDone"&gt; &lt;/div&gt; &lt;/tal:x&gt; </code></pre> <p>And here is the error.</p> <pre><code>Compilation failed zope.tal.taldefs.TALError: TAL attributes on &lt;tal:x&gt; require explicit &lt;/tal:x&gt; </code></pre> <p>I tried with a Python script but it didn't work either.</p> <pre><code>&lt;div id="notaccordion"&gt; &lt;tal:x repeat="item python:range(26)"&gt; &lt;tal:x define="global block_name python:current.values()[0]['block_name']"&gt; &lt;tal:x condition="python:isDone"&gt; &lt;tal:x content="python:context[close_div]()"&gt; &lt;/tal:x&gt; &lt;/tal:x&gt; &lt;tal:x condition="python:not isDone"&gt; &lt;tal:x replace="python:block_name"&gt; &lt;/tal:x&gt; &lt;tal:x content="python:context[open_div]()"&gt; &lt;/tal:x&gt; &lt;/tal:x&gt; &lt;/tal:x&gt; &lt;/tal:x&gt; &lt;/div&gt; </code></pre> <p>With <code>close_div</code> script:</p> <pre><code>print '&lt;/div&gt;' return printed </code></pre> <p>It returns <code>&amp;lt;/div&amp;gt;</code> instead of <code>&lt;/div&gt;</code></p> <p>If you wonder why I'm doing it. I have a tree structure that I need to display. Since I (think I) can't do it recursively, I try to emulate it using a LIFO list. And <code>current</code> is my current node.</p> <p>I try to achieve this (node is dict of dict... used as a tree) :</p> <pre><code>lifo = list() lifo.append([node, False]) while lifo: current, isDone = lifo[-1] block = current.keys()[0] if isDone: print '&lt;/div&gt;' lifo.pop() else: lifo[-1][1] = True print '&lt;div&gt;' print block children = current[block].get('children', {}) if children: for childBlock, childValue in children.items(): lifo.append([{childBlock:childValue}, False]) </code></pre> <p>Any help or suggestion is appreciated</p>