tag_parser/basetags.py
def validate_args(cls, tag_name, *args, **kwargs):
        """
        Validate the syntax of the template tag.
        """
        if cls.min_args is not None and len(args) < cls.min_args:
            if cls.min_args == 1:
                raise TemplateSyntaxError("'{0}' tag requires at least {1} argument".format(tag_name, cls.min_args))
            else:
                raise TemplateSyntaxError("'{0}' tag requires at least {1} arguments".format(tag_name, cls.min_args))

        if cls.max_args is not None and len(args) > cls.max_args:
            if cls.max_args == 0:
                if cls.allowed_kwargs:
                    raise TemplateSyntaxError("'{0}' tag only allows keywords arguments, for example {1}=\"...\".".format(tag_name, cls.allowed_kwargs[0]))
                else:
                    raise TemplateSyntaxError("'{0}' tag doesn't support any arguments".format(tag_name))
            elif cls.max_args == 1:
                raise TemplateSyntaxError("'{0}' tag only allows {1} argument.".format(tag_name, cls.max_args))
            else:
                raise TemplateSyntaxError("'{0}' tag only allows {1} arguments.".format(tag_name, cls.max_args))
def validate_args(cls, tag_name, *args, **kwargs):
        """
        Validate the syntax of the template tag.
        """
        if cls.min_args is not None and len(args) < cls.min_args:
            if cls.min_args == 1:
                raise TemplateSyntaxError("'{0}' tag requires at least {1} argument".format(tag_name, cls.min_args))
            else:
                raise TemplateSyntaxError("'{0}' tag requires at least {1} arguments".format(tag_name, cls.min_args))

        if cls.max_args is not None and len(args) > cls.max_args:
            if cls.max_args == 0:
                if cls.allowed_kwargs:
                    raise TemplateSyntaxError("'{0}' tag only allows keywords arguments, for example {1}=\"...\".".format(tag_name, cls.allowed_kwargs[0]))
                else:
                    raise TemplateSyntaxError("'{0}' tag doesn't support any arguments".format(tag_name))
            elif cls.max_args == 1:
                raise TemplateSyntaxError("'{0}' tag only allows {1} argument.".format(tag_name, cls.max_args))
            else:
                raise TemplateSyntaxError("'{0}' tag only allows {1} arguments.".format(tag_name, cls.max_args))
def validate_args ( cls , tag_name , * args , * * kwargs ) : if cls . min_args is not None and len ( args ) < cls . min_args : if cls . min_args == 1 : raise TemplateSyntaxError ( "'{0}' tag requires at least {1} argument" . format ( tag_name , cls . min_args ) ) else : raise TemplateSyntaxError ( "'{0}' tag requires at least {1} arguments" . format ( tag_name , cls . min_args ) ) if cls . max_args is not None and len ( args ) > cls . max_args : if cls . max_args == 0 : if cls . allowed_kwargs : raise TemplateSyntaxError ( "'{0}' tag only allows keywords arguments, for example {1}=\"...\"." . format ( tag_name , cls . allowed_kwargs [ 0 ] ) ) else : raise TemplateSyntaxError ( "'{0}' tag doesn't support any arguments" . format ( tag_name ) ) elif cls . max_args == 1 : raise TemplateSyntaxError ( "'{0}' tag only allows {1} argument." . format ( tag_name , cls . max_args ) ) else : raise TemplateSyntaxError ( "'{0}' tag only allows {1} arguments." . format ( tag_name , cls . max_args ) )
Validate the syntax of the template tag.
Validate the syntax of the template tag .