def render(self, composite): """Renders a composite, adding scripts and styles. """ text = CommonUI.render(self, composite) fragments = self.getFragments(composite) if fragments['contentmenu']: match = start_of_contentmenu_search(text) index = match and match.start(0) or -1 text = "%s%s%s" % (text[:index], fragments['contentmenu'], text[index:]) return text
def getFragments(self, composite): """Returns the fragments to be inserted in design mode. """ params = { "tool": aq_parent(aq_inner(aq_parent(aq_inner(self)))), "ui": self, "composite": composite, } contentmenu = "" for t in self.contentmenu_templates: contentmenu += str(t.__of__(self)(**params)) result = CommonUI.getFragments(self, composite) result["contentmenu"] = contentmenu return result