def render(self, info=None, format='html', encoding='unicode'): ''' Render string from template. :keyword info: data to substitute into a document :keyword str format: HTML doctype to use for string :param str encoding: encoding type for return string ''' # substitute any info into the document if info is not None: self.__imod__(info) tree = _copytree(self._tree) # use XHTML 1.0 doctype if format == 'html': # strip namespace prefix from HTML xhtml_to_html(tree) doc = htostring(tree, encoding=encoding, doctype=_html5) # use XHTML 1.1 doctype elif format == 'xhtml10': doc = htostring( tree, method='xml', encoding=encoding, doctype=_xhtml10, ) # use HTML 5 doctype elif format == 'xhtml11': doc = htostring( tree, method='xml', encoding=encoding, doctype=_xhtml11, ) return doc
def tounicode(tree_or_node, **kwargs): kwargs['encoding'] = str return htostring(tree_or_node, **kwargs)
def tounicode(tree_or_node, **kwargs): kwargs['encoding'] = unicode return htostring(tree_or_node, **kwargs)