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