# Path: djedi/compat.py
# def generic_tag_compiler(parser, token, params, varargs, varkw, defaults,
#                          name, takes_context, node_class):
#     """
#     Returns a template.Node subclass.
# 
#     This got inlined into django.template.library since Django since 1.9, this here
#     is a copypasta replacement:
#     https://github.com/django/django/blob/stable/1.8.x/django/template/base.py#L1089
#     """
#     bits = token.split_contents()[1:]
#     args, kwargs = parse_bits(parser, bits, params, varargs, varkw,
#                               defaults, takes_context, name)
#     return node_class(takes_context, args, kwargs)
# 
# def getargspec(func):
#     spec = getfullargspec(func)
#     return ArgSpec(
#         args=spec.args,
#         varargs=spec.varargs,
#         keywords=spec.varkw,
#         defaults=spec.defaults,
#     )


from functools import partial
from django import template
from django.template import Context
from django.template.base import Node, TemplateSyntaxError
from ..compat import generic_tag_compiler, getargspec


register = template.Library()


def lazy_tag(self, func=None, takes_context=None, name=None, node_class=None):
    """
    A tag function decorator, injected on Django's template tag library, similar to simple_tag().
    The decorated function gets called when the template node tree is built and should return
    another function, responsible for the output, that later will be called within the rendering phase.

    Note: if decorated with takes_context=True, context will not be available in the init phase.

    @register.lazy_tag(takes_context=True)
    def x(context, a, b, c=True, d=False):
        # Init phase (no context)

        def render(context):
            # Render phase
            return u'Content of argument a: %s' % a

        return render
    """
    def dec(func):

# Path: djedi/compat.py
# def generic_tag_compiler(parser, token, params, varargs, varkw, defaults,
#                          name, takes_context, node_class):
#     """
#     Returns a template.Node subclass.
# 
#     This got inlined into django.template.library since Django since 1.9, this here
#     is a copypasta replacement:
#     https://github.com/django/django/blob/stable/1.8.x/django/template/base.py#L1089
#     """
#     bits = token.split_contents()[1:]
#     args, kwargs = parse_bits(parser, bits, params, varargs, varkw,
#                               defaults, takes_context, name)
#     return node_class(takes_context, args, kwargs)
# 
# def getargspec(func):
#     spec = getfullargspec(func)
#     return ArgSpec(
#         args=spec.args,
#         varargs=spec.varargs,
#         keywords=spec.varkw,
#         defaults=spec.defaults,
#     )


# Path: djedi/templatetags/template.py
from functools import partial
from django import template
from django.template import Context
from django.template.base import Node, TemplateSyntaxError
from ..compat import generic_tag_compiler, getargspec



register = template.Library()


def lazy_tag(self, func=None, takes_context=None, name=None, node_class=None):
    """
    A tag function decorator, injected on Django's template tag library, similar to simple_tag().
    The decorated function gets called when the template node tree is built and should return
    another function, responsible for the output, that later will be called within the rendering phase.

    Note: if decorated with takes_context=True, context will not be available in the init phase.

    @register.lazy_tag(takes_context=True)
    def x(context, a, b, c=True, d=False):
        # Init phase (no context)

        def render(context):
            # Render phase
            return u'Content of argument a: %s' % a

        return render
    """
    def dec(func):

        params, varargs, varkw, defaults = getargspec(func)