[ZPT] CVS: Packages/TAL - TALInterpreter.py:1.31

guido@digicool.com guido@digicool.com
Fri, 6 Apr 2001 17:35:04 -0400 (EDT)


Update of /cvs-repository/Packages/TAL
In directory korak:/tmp/cvs-serv32507

Modified Files:
	TALInterpreter.py 
Log Message:
Change attribute replacement so that Boolean HTML attributes can be
set or cleared by specifying any true or false value.

(XXX I wonder if this should be recognized at compile time rather than
at interpretation time; oh well, this works.)



--- Updated File TALInterpreter.py in package Packages/TAL --
--- TALInterpreter.py	2001/04/06 01:00:16	1.30
+++ TALInterpreter.py	2001/04/06 21:35:03	1.31
@@ -252,15 +252,19 @@
             if len(item) > 2:
                 action = item[2]
                 if action == "replace" and len(item) > 3 and self.tal:
-                    value = self.engine.evaluateText(item[3])
+                    if self.html and string.lower(name) in BOOLEAN_HTML_ATTRS:
+                        ok = self.engine.evaluateBoolean(item[3])
+                        if not ok:
+                            continue
+                        else:
+                            value = None
+                    else:
+                        value = self.engine.evaluateText(item[3])
                 elif (action == "macroHack" and self.currentMacro and
                       name[-13:] == ":define-macro" and self.metal):
                     name = name[:-13] + ":use-macro"
                     value = self.currentMacro
-            if (self.html and not value and
-                string.lower(name) in BOOLEAN_HTML_ATTRS):
-                s = name
-            elif value is None:
+            if value is None:
                 s = name
             else:
                 s = "%s=%s" % (name, quote(value))