[Checkins] SVN: Sandbox/malthe/chameleon.zpt/ Tags are now omitted if tal:content expression evaluates to None.
Malthe Borch
mborch at gmail.com
Sun Oct 12 22:52:17 EDT 2008
Log message for revision 92089:
Tags are now omitted if tal:content expression evaluates to None.
Changed:
U Sandbox/malthe/chameleon.zpt/CHANGES.txt
U Sandbox/malthe/chameleon.zpt/src/chameleon/zpt/language.py
U Sandbox/malthe/chameleon.zpt/src/chameleon/zpt/language.txt
-=-
Modified: Sandbox/malthe/chameleon.zpt/CHANGES.txt
===================================================================
--- Sandbox/malthe/chameleon.zpt/CHANGES.txt 2008-10-13 02:48:35 UTC (rev 92088)
+++ Sandbox/malthe/chameleon.zpt/CHANGES.txt 2008-10-13 02:52:16 UTC (rev 92089)
@@ -4,6 +4,11 @@
Head
~~~~
+- Tags are now omitted if a "tal:content" expression evaluates to
+ ``None``. This behavior differs from the reference implementation,
+ but does away with the need for a similar "tal:condition"
+ attribute. [malthe]
+
1.0a2 (released 10/2/2008)
~~~~~~~~~~~~~~~~~~~~~~~~~~
Modified: Sandbox/malthe/chameleon.zpt/src/chameleon/zpt/language.py
===================================================================
--- Sandbox/malthe/chameleon.zpt/src/chameleon/zpt/language.py 2008-10-13 02:48:35 UTC (rev 92088)
+++ Sandbox/malthe/chameleon.zpt/src/chameleon/zpt/language.py 2008-10-13 02:52:16 UTC (rev 92089)
@@ -18,6 +18,8 @@
"""
class node(translation.Node):
+ content_symbol = '_content'
+
@property
def omit(self):
if self.element.tal_omit is not None:
@@ -28,12 +30,24 @@
return True
if self.element.metal_use or self.element.metal_fillslot:
return True
-
+ if self.content is not None:
+ return types.parts(
+ (types.value("%s is None" % self.content_symbol),))
+
@property
def define(self):
return self.element.tal_define
@property
+ def assign(self):
+ content = self._content
+ if content is not None:
+ definition = (
+ types.declaration((self.content_symbol,)),
+ content)
+ return types.definitions((definition,))
+
+ @property
def condition(self):
return self.element.tal_condition
@@ -43,9 +57,18 @@
@property
def content(self):
- return self.element.tal_content or self.element.tal_replace or \
+ content = self._content
+ if content is not None:
+ if isinstance(content, types.escape):
+ return types.escape((types.value(self.content_symbol),))
+ return types.parts((types.value(self.content_symbol),))
+
+ @property
+ def _content(self):
+ return self.element.tal_content or \
+ self.element.tal_replace or \
self.element.meta_replace
-
+
@property
def skip(self):
if self.define_slot:
Modified: Sandbox/malthe/chameleon.zpt/src/chameleon/zpt/language.txt
===================================================================
--- Sandbox/malthe/chameleon.zpt/src/chameleon/zpt/language.txt 2008-10-13 02:48:35 UTC (rev 92088)
+++ Sandbox/malthe/chameleon.zpt/src/chameleon/zpt/language.txt 2008-10-13 02:52:16 UTC (rev 92089)
@@ -17,7 +17,7 @@
Hello, world!
<BLANKLINE>
-tal:define, tal:attributes, tal:contents
+tal:define, tal:attributes, tal:content, tal:replace
>>> print render("""\
... <div xmlns="http://www.w3.org/1999/xhtml"
@@ -36,7 +36,6 @@
<span class="defabc" style="hij" onclick="alert();" id="test">abcghi</span>
Hello World!
Hello World!
- <span></span>
</div>
tal:attributes 'checked' and 'selected' toggles
More information about the Checkins
mailing list