Commit a852620a authored by Guido van Rossum's avatar Guido van Rossum

Allow define-slot and fill-slot on the same tag.

parent 30ebde7b
......@@ -379,8 +379,9 @@ class TALGenerator:
replace = taldict.get("replace")
attrsubst = taldict.get("attributes")
onError = taldict.get("on-error")
if len(metaldict) > 1:
raise METALError("at most one METAL attribute per element",
if len(metaldict) > 1 and (defineMacro or useMacro):
raise METALError("define-macro and use-macro cannot be used "
"together or with define-slot or fill-slot",
position)
if content and replace:
raise TALError("content and replace are mutually exclusive",
......@@ -402,12 +403,12 @@ class TALGenerator:
self.pushSlots()
self.pushProgram()
todo["useMacro"] = useMacro
if defineSlot:
self.pushProgram()
todo["defineSlot"] = defineSlot
if fillSlot:
self.pushProgram()
todo["fillSlot"] = fillSlot
if defineSlot:
self.pushProgram()
todo["defineSlot"] = defineSlot
if taldict:
self.emit("beginScope")
self.emit("rawAttrs", self.makeAttrDict(attrlist))
......@@ -504,14 +505,14 @@ class TALGenerator:
self.emitOnError(name, onError, position)
if scope:
self.emit("endScope")
if defineMacro:
self.emitDefineMacro(defineMacro, position)
if useMacro:
self.emitUseMacro(useMacro)
if defineSlot:
self.emitDefineSlot(defineSlot)
if fillSlot:
self.emitFillSlot(fillSlot, position)
if useMacro:
self.emitUseMacro(useMacro)
if defineMacro:
self.emitDefineMacro(defineMacro, position)
def test():
t = TALGenerator()
......
......@@ -8,8 +8,8 @@
<div metal:define-macro="OUTER">
<div metal:use-macro="INNER">
<xxx metal:fill-slot="INNERSLOT">
<xxx metal:define-slot="OUTERSLOT">OUTERSLOT</xxx>
<xxx metal:define-slot="OUTERSLOT" metal:fill-slot="INNERSLOT">
OUTERSLOT
</xxx>
</div>
</div>
......
......@@ -9,23 +9,21 @@
<div>
<span>
<xxx>
<xxx>OUTERSLOT</xxx>
OUTERSLOT
</xxx>
</span>
</div>
<div>
<span>
<xxx>
<div>outer-argument</div>
</xxx>
<div>outer-argument</div>
</span>
</div>
<div>
<span>
<xxx>
<xxx>OUTERSLOT</xxx>
OUTERSLOT
</xxx>
</span>
</div>
......@@ -468,8 +468,6 @@ class TALGeneratorTestCases(TestCaseBase):
self._should_error("<html metal:use-macro='x'>" +
2*"<p metal:fill-slot='y' />" + "</html>", exc)
self._should_error("<p metal:foobar='x' />", exc)
self._should_error("<p metal:define-slot='x' metal:fill-slot='x' />",
exc)
self._should_error("<p metal:define-macro='x'>", exc)
......
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