Commit 648f151c authored by Guido van Rossum's avatar Guido van Rossum

Use the same nasty hack I just checked into TALParser.py to tidy up

the generated XML for repeated elements.  This also required slightly
refactoring the way beginScope/endScope are emitted for repeated
element: now we open and close two scopes if an element has both a
tal:define and a tal:repeat attribute -- just like TALParser does.
parent 57e848d2
......@@ -266,11 +266,9 @@ class TALCompiler(METALCompiler):
# Overriding METAL method to compile TAL statements
def compileElement(self, node):
defines = node.getAttributeNS(ZOPE_TAL_NS, "define")
repeat = node.getAttributeNS(ZOPE_TAL_NS, "repeat")
if defines or repeat:
if defines:
self.emit("beginScope")
if defines:
self.emitDefines(defines)
self.emitDefines(defines)
self.conditionalElement(node)
self.emit("endScope")
else:
......@@ -332,9 +330,14 @@ class TALCompiler(METALCompiler):
return 1
def doRepeat(self, node, arg):
whitespace = self.unEmitNewlineWhitespace()
self.emit("beginScope")
self.pushProgram()
if whitespace:
self.emitText(whitespace)
self.emitElement(node)
self.emitRepeat(arg)
self.emit("endScope")
return 1
def getAttributeReplacements(self, node):
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment