
Hullo,
I recently encountered a problem with the following XML snippet:
<input type="checkbox" n:data="m_friend" n:render="if"> <n:attr name="checked">true</n:attr> </input>
where the page defines:
def render_if(self, ctx, data): if data: return self.tag else: return self.tag.clear()
The problem is that due to the way nevow:attr is parsed the <input> ends up with an unwanted checked attribute.
One way to fix this is to clear Tag valued attributes when a tag is clear()'d. The type test in the following patch is possibly a bit too hacky, but I'm hoping someone will be able to improve on it :)
Cheers, Joe
Index: stan.py =================================================================== --- stan.py (revision 1346) +++ stan.py (working copy) @@ -352,6 +352,9 @@ """Clear any existing children from this tag. """ self._specials = {} + for (a,v) in self.attributes.items(): + if type(v)!=unicode: + del self.attributes[a] self.children = [] return self
participants (1)
-
Joe Halliwell