[Checkins] SVN: z3c.pt/trunk/ Skip elements in a define-slot clause if its being filled by the calling template.
Malthe Borch
mborch at gmail.com
Sat Sep 13 18:38:34 EDT 2008
Log message for revision 91131:
Skip elements in a define-slot clause if its being filled by the calling template.
Changed:
U z3c.pt/trunk/CHANGES.txt
U z3c.pt/trunk/src/z3c/pt/zpt.py
U z3c.pt/trunk/src/z3c/pt/zpt.txt
-=-
Modified: z3c.pt/trunk/CHANGES.txt
===================================================================
--- z3c.pt/trunk/CHANGES.txt 2008-09-13 21:53:52 UTC (rev 91130)
+++ z3c.pt/trunk/CHANGES.txt 2008-09-13 22:38:34 UTC (rev 91131)
@@ -185,6 +185,9 @@
Bugfixes
+- Skip elements in a "define-slot" clause if its being filled by the
+ calling template. [malthe]
+
- Support "fill-slot" on elements with METAL namespace. [malthe]
- Omit element text when rendering macro. [malthe]
Modified: z3c.pt/trunk/src/z3c/pt/zpt.py
===================================================================
--- z3c.pt/trunk/src/z3c/pt/zpt.py 2008-09-13 21:53:52 UTC (rev 91130)
+++ z3c.pt/trunk/src/z3c/pt/zpt.py 2008-09-13 22:38:34 UTC (rev 91131)
@@ -2,6 +2,7 @@
import translation
import interfaces
+import itertools
import utils
import config
import etree
@@ -45,6 +46,11 @@
@property
def skip(self):
+ if self.define_slot:
+ variable = self.symbols.slot + self.define_slot
+ if variable in itertools.chain(*self.stream.scope):
+ return True
+
return self.content or \
self.use_macro or self.translate is not None
Modified: z3c.pt/trunk/src/z3c/pt/zpt.txt
===================================================================
--- z3c.pt/trunk/src/z3c/pt/zpt.txt 2008-09-13 21:53:52 UTC (rev 91130)
+++ z3c.pt/trunk/src/z3c/pt/zpt.txt 2008-09-13 22:38:34 UTC (rev 91131)
@@ -27,7 +27,7 @@
... tal:define="a 'abc'"
... tal:attributes="class 'def' + a; style 'hij'; onClick 'alert();'"
... tal:content="a + 'ghi'" />
- ... <span tal:replace="'Hello World!'">Hello Universe!</span>
+ ... <span tal:replace="'Hello World!'">Hello <b>Universe</b>!</span>
... <span tal:replace="'Hello World!'"><b>Hello Universe!</b></span>
... <span tal:content="None" />
... </div>""")
@@ -315,7 +315,8 @@
... xmlns:tal="http://xml.zope.org/namespaces/tal"
... xmlns:metal="http://xml.zope.org/namespaces/metal">
... <div metal:define-macro="greeting">
- ... Hello, <b class="name" metal:define-slot="name">stranger!</b>
+ ... Hey, <span class="name" metal:define-slot="name">
+ ... a <em>stranger!</em></span>
... </div>
... <div metal:use-macro="template.macros['greeting']">
... This will be omitted
@@ -340,26 +341,25 @@
>>> print render_zpt(body, template=template)
<div>
<div>
- Hello, <b class="name">stranger!</b>
+ Hey, <span class="name">
+ a <em>stranger!</em></span>
</div>
- <BLANKLINE>
- <div>
- Hello, <b class="name">earth!</b>
+ <div>
+ Hey, <span class="name">earth!</span>
</div>
<BLANKLINE>
- <BLANKLINE>
- <div>
- Hello, <b class="name">earth!</b>
+ <div>
+ Hey, <span class="name">earth!</span>
</div>
<BLANKLINE>
- <BLANKLINE>
- <div>
- Hello, <b class="name">stranger!</b>
+ <div>
+ Hey, <span class="name">
+ a <em>stranger!</em></span>
</div>
<BLANKLINE>
- <BLANKLINE>
- <div>
- Hello, <b class="name">stranger!</b>
+ <div>
+ Hey, <span class="name">
+ a <em>stranger!</em></span>
</div>
<BLANKLINE>
</div>
More information about the Checkins
mailing list