def METHOD_NAME(funcname, filename, directory):
    import functools
    import inspect
    path       = os.path.join(directory, filename)
    template   = lookup_template(path)
    local_ctx = get_context_from_dirpath(directory)
    def res(*args, **kwargs):
        with render_global.go_inside() as was_inside:
            with context.local(**local_ctx):
                lines = template.render(*args, **kwargs).split('\n')
        for i, line in enumerate(lines):
            def islabelchar(c):
                return c.isalnum() or c == '.' or c == '_'
            if ':' in line and islabelchar(line.lstrip()[0]):
                line = line.lstrip()
            elif line.startswith(' '):
                 line = '    ' + line.lstrip()
            lines[i] = line
        while lines and not lines[-1]: lines.pop()
        while lines and not lines[0]:  lines.pop(0)
        s = '\n'.join(lines)
        while '\n\n\n' in s:
            s = s.replace('\n\n\n', '\n\n')
        if was_inside:
            return s
        else:
            return s + '\n'
    # Setting _relpath is a slight hack only used to get better documentation
    res._relpath = path
    res.__module__ = 'pwnlib.shellcraft.' + os.path.dirname(path).replace('/','.')
    res.__name__ = res.__qualname__ = funcname
    res.__doc__ = inspect.cleandoc(template.module.__doc__ or '')
    if hasattr(inspect, 'signature'):
        sig = inspect.signature(template.module.render_body)
        sig = sig.replace(parameters=list(sig.parameters.values())[1:-1])
        res.__signature__ = sig
    @functools.wraps(res)
    def function(*a):
        return sys.modules[res.__module__].function(res.__name__, res, *a)
    @functools.wraps(res)
    def call(*a):
        return sys.modules[res.__module__].call(res.__name__, *a)
    res.function = function
    res.call     = call
    return res