Commit 72f4c314 authored by Guido van Rossum's avatar Guido van Rossum

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.)
parent 7c6b3264
...@@ -252,15 +252,19 @@ class TALInterpreter: ...@@ -252,15 +252,19 @@ class TALInterpreter:
if len(item) > 2: if len(item) > 2:
action = item[2] action = item[2]
if action == "replace" and len(item) > 3 and self.tal: 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 elif (action == "macroHack" and self.currentMacro and
name[-13:] == ":define-macro" and self.metal): name[-13:] == ":define-macro" and self.metal):
name = name[:-13] + ":use-macro" name = name[:-13] + ":use-macro"
value = self.currentMacro value = self.currentMacro
if (self.html and not value and if value is None:
string.lower(name) in BOOLEAN_HTML_ATTRS):
s = name
elif value is None:
s = name s = name
else: else:
s = "%s=%s" % (name, quote(value)) s = "%s=%s" % (name, quote(value))
......
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