'Compile the template to a Python function.'

def translate(self):

    (expressions, varnames, funcnames) = self.expr.translate()
    argnames = []
    for varname in varnames:
        argnames.append((VARIABLE_PREFIX + varname))
    for funcname in funcnames:
        argnames.append((FUNCTION_PREFIX + funcname))
    func = compile_func(argnames, [ast.Return(ast.List(expressions, ast.Load()))])
    def wrapper_func(values={}, functions={}):
        args = {}
        for varname in varnames:
            args[(VARIABLE_PREFIX + varname)] = values[varname]
        for funcname in funcnames:
            args[(FUNCTION_PREFIX + funcname)] = functions[funcname]
        parts = func(**args)
        return u''.join(parts)
    return wrapper_func
