def toHtml(self, valueDict=None, formatted=False): oldChildElements = self.childElements self.reset() for childElement in oldChildElements: self.__modifyChild__(childElement) lineBreak = Box.addChildElement(self, LineBreak()) returnValue = Box.toHtml(self, valueDict, formatted=formatted) self.childElements = oldChildElements return returnValue
def toHtml(self, formatted=False, *args, **kwargs): oldChildElements = self.childElements self.reset() for childElement in oldChildElements: self.__modifyChild__(childElement) lineBreak = Box.addChildElement(self, LineBreak()) returnValue = Box.toHtml(self, formatted=formatted, *args, **kwargs) self._childElements = oldChildElements return returnValue
def __modifyChild__(self, childElement): width = childElement.style.pop('width', '') align = childElement.style.pop('float', 'left') if width == "0" or width == "hide": self.childElements.append(childElement) if not childElement.displayable: self.childElements.append(childElement) return if not childElement.tagName or width: container = Box.addChildElement(self, Box()) container.addChildElement(childElement) else: if not childElement.isBlockElement(): childElement.addClass("WBlock") container = childElement self.childElements.append(childElement) container.style['float'] = align if width: container.style['vertical-align'] = 'middle' container.style['width'] = width
def __modifyChild__(self, childElement): height = childElement.style.pop('height', '') if not childElement.displayable: self.childElements.append(childElement) elif not childElement.tagName or height: container = Box() container.style['height'] = height childElement.style['height'] = "100%" container.style['clear'] = "both" container.addChildElement(childElement) return Box.addChildElement(self, container) else: childElement.style['clear'] = "both" if not childElement.isBlockElement(): childElement.addClass("WBlock") self.childElements.append(childElement)