'Compile the given template into a rendering function::
render(qweb, append, values)
where ``qweb`` is a QWeb instance, ``append`` is a unary function to
collect strings into a result, and ``values`` are the values to render.'

def compile(self, template, options):

    if (options is None):
        options = {}
    _options = dict(options)
    options = frozendict(options)
    (element, document) = self.get_template(template, options)
    name = element.get('t-name', 'unknown')
    _options['template'] = template
    _options['ast_calls'] = []
    _options['root'] = element.getroottree()
    _options['last_path_node'] = None
    astmod = self._base_module()
    try:
        body = self._compile_node(element, _options)
        ast_calls = _options['ast_calls']
        _options['ast_calls'] = []
        def_name = self._create_def(_options, body, prefix=('template_%s' % name.replace('.', '_')))
        _options['ast_calls'] += ast_calls
    except QWebException as e:
        raise e
    except Exception as e:
        path = _options['last_path_node']
        node = element.getroottree().xpath(path)
        raise QWebException('Error    when    compiling    AST', e, path, etree.tostring(node[0]), name)
    astmod.body.extend(_options['ast_calls'])
    if ('profile' in options):
        self._profiling(astmod, _options)
    ast.fix_missing_locations(astmod)
    try:
        ns = {}
        unsafe_eval(compile(astmod, '<template>', 'exec'), ns)
        compiled = ns[def_name]
    except QWebException as e:
        raise e
    except Exception as e:
        path = _options['last_path_node']
        node = element.getroottree().xpath(path)
        raise QWebException('Error    when    compiling    AST', e, path, (node and etree.tostring(node[0])), name)
    def _compiled_fn(self, append, values):
        log = {'last_path_node': None}
        values = dict(self.default_values(), **values)
        try:
            return compiled(self, append, values, options, log)
        except QWebException as e:
            raise e
        except Exception as e:
            path = log['last_path_node']
            (element, document) = self.get_template(template, options)
            node = element.getroottree().xpath(path)
            raise QWebException('Error    to    render    compiling    AST', e, path, (node and etree.tostring(node[0])), name)
    return _compiled_fn
