'Retrieve the given template, and return it as a pair ``(element,
document)``, where ``element`` is an etree, and ``document`` is the
string document that contains ``element``.'

def get_template(self, template, options):

    if isinstance(template, etree._Element):
        document = template
        template = etree.tostring(template)
        return (document, template)
    else:
        try:
            document = options.get('load', self.load)(template, options)
        except QWebException as e:
            raise e
        except Exception as e:
            raise QWebException('load    could    not    load    template', name=template)
    if (document is not None):
        if isinstance(document, etree._Element):
            element = document
            document = etree.tostring(document)
        elif document.startswith('<?xml'):
            element = etree.fromstring(document)
        else:
            element = etree.parse(document).getroot()
        for node in element:
            if (node.get('t-name') == str(template)):
                return (node, document)
    raise QWebException('Template    not    found', name=template)
