def parse(cls, parser, token): """ Parse the "as var" syntax. """ bits, as_var = parse_as_var(parser, token) tag_name, args, kwargs = parse_token_kwargs(parser, bits, ('template',) + cls.allowed_kwargs, compile_args=cls.compile_args, compile_kwargs=cls.compile_kwargs) # Pass through standard chain cls.validate_args(tag_name, *args) return cls(tag_name, as_var, *args, **kwargs)
def parse(cls, parser, token): """ Parse the tag, instantiate the class. """ # There is no __init__(self, parser, token) method in this class design # to discourage the @register.tag decorator on the class because that prevents tag inheritance. tag_name, args, kwargs = parse_token_kwargs( parser, token, allowed_kwargs=cls.allowed_kwargs, compile_args=cls.compile_args, compile_kwargs=cls.compile_kwargs ) cls.validate_args(tag_name, *args, **kwargs) return cls(tag_name, *args, **kwargs)
def parse(cls, parser, token): """ Parse the tag, instantiate the class. """ tag_name, args, kwargs = parse_token_kwargs( parser, token, allowed_kwargs=cls.allowed_kwargs, compile_args=cls.compile_args, compile_kwargs=cls.compile_kwargs) cls.validate_args(tag_name, *args, **kwargs) nodelist = parser.parse(('end{}'.format(tag_name), )) parser.delete_first_token() return cls(tag_name, nodelist, *args, **kwargs)
def parse(cls, parser, token): """ Parse the tag, instantiate the class. """ tag_name, args, kwargs = parse_token_kwargs( parser, token, allowed_kwargs=cls.allowed_kwargs, compile_args=cls.compile_args, compile_kwargs=cls.compile_kwargs ) cls.validate_args(tag_name, *args, **kwargs) nodelist = parser.parse(('end{}'.format(tag_name),)) parser.delete_first_token() return cls(tag_name, nodelist, *args, **kwargs)
def parse(cls, parser, token): """ Parse the tag, instantiate the class. :type parser: django.template.base.Parser :type token: django.template.base.Token """ tag_name, args, kwargs = parse_token_kwargs( parser, token, allowed_kwargs=cls.allowed_kwargs, compile_args=cls.compile_args, compile_kwargs=cls.compile_kwargs ) cls.validate_args(tag_name, *args, **kwargs) if cls.end_tag_name: kwargs['nodelist'] = parser.parse((cls.end_tag_name,)) parser.delete_first_token() return cls(tag_name, *args, **kwargs)