def __render__(self): node = self if node.attrs: # TODO: use real quoting attrs = " " + " ".join("%s=%s" % (k, macros.quote(v.__render__())) for (k, v) in node.attrs.items()) else: attrs = "" if not node.__children__: # render single tag return "<%s%s />" % (node.tag, attrs) else: # render close/open return "<%s%s>%s</%s>" % (node.tag, attrs, BaseNode.__render__(self), node.tag)
def _sub(match): try: return macros.quote(eval(match.group("id"), env)) except KeyError: raise KeyError, "Invalid token: %s" % match.group("id")