[ZPT] CVS: Packages/TAL - TALGenerator.py:1.33
guido@digicool.com
guido@digicool.com
Wed, 11 Apr 2001 14:54:28 -0400 (EDT)
Update of /cvs-repository/Packages/TAL
In directory korak:/tmp/cvs-serv17795
Modified Files:
TALGenerator.py
Log Message:
Allow tal:repeat to be combined with tal:replace or tal:content,
repeating the substitution.
Why didn't we think of this before?!
--- Updated File TALGenerator.py in package Packages/TAL --
--- TALGenerator.py 2001/04/10 02:09:18 1.32
+++ TALGenerator.py 2001/04/11 18:54:27 1.33
@@ -374,20 +374,16 @@
fillSlot = metaldict.get("fill-slot")
define = taldict.get("define")
condition = taldict.get("condition")
+ repeat = taldict.get("repeat")
content = taldict.get("content")
replace = taldict.get("replace")
- repeat = taldict.get("repeat")
attrsubst = taldict.get("attributes")
onError = taldict.get("on-error")
if len(metaldict) > 1:
raise METALError("at most one METAL attribute per element",
position)
- n = 0
- if content: n = n+1
- if replace: n = n+1
- if repeat: n = n+1
- if n > 1:
- raise TALError("at most one of content, replace, repeat",
+ if content and replace:
+ raise TALError("content and replace are mutually exclusive",
position)
repeatWhitespace = None
@@ -425,17 +421,17 @@
if condition:
self.pushProgram()
todo["condition"] = condition
- if content:
- todo["content"] = content
- elif replace:
- todo["replace"] = replace
- self.pushProgram()
- elif repeat:
+ if repeat:
todo["repeat"] = repeat
self.emit("beginScope")
self.pushProgram()
if repeatWhitespace:
self.emitText(repeatWhitespace)
+ if content:
+ todo["content"] = content
+ if replace:
+ todo["replace"] = replace
+ self.pushProgram()
if attrsubst:
repldict = parseAttributeReplacements(attrsubst)
for key, value in repldict.items():
@@ -467,8 +463,8 @@
useMacro = todo.get("useMacro")
defineSlot = todo.get("defineSlot")
fillSlot = todo.get("fillSlot")
- content = todo.get("content")
repeat = todo.get("repeat")
+ content = todo.get("content")
replace = todo.get("replace")
condition = todo.get("condition")
onError = todo.get("onError")
@@ -489,11 +485,11 @@
self.emitSubstitution(content, {}, position)
if not isend:
self.emitEndTag(name)
+ if replace:
+ self.emitSubstitution(replace, repldict, position)
if repeat:
self.emitRepeat(repeat, position)
self.emit("endScope")
- if replace:
- self.emitSubstitution(replace, repldict, position)
if condition:
self.emitCondition(condition)
if onError: