def parse_args_kwargs(parser, token):
bits = token.contents.split('<STR_LIT:U+0020>')<EOL>if len(bits) <= <NUM_LIT:1>:<EOL><INDENT>raise template.TemplateSyntaxError("<STR_LIT>" % bits[<NUM_LIT:0>])<EOL><DEDENT>if token.contents[<NUM_LIT>] == '<STR_LIT:">':<EOL><INDENT>end_quote = token.contents.index('<STR_LIT:">', <NUM_LIT>) + <NUM_LIT:1><EOL>args = [template.Variable(token.contents[<NUM_LIT>:end_quote])]<EOL>kwargs_start = end_quote<EOL><DEDENT>else:<EOL><INDENT>try:<EOL><INDENT>next_space = token.contents.index('<STR_LIT:U+0020>', <NUM_LIT>)<EOL>kwargs_start = next_space + <NUM_LIT:1><EOL><DEDENT>except ValueError:<EOL><INDENT>next_space = None<EOL>kwargs_start = None<EOL><DEDENT>args = [template.Variable(token.contents[<NUM_LIT>:next_space])]<EOL><DEDENT>kwargs = {}<EOL>kwargs_list = token.contents[kwargs_start:].split('<STR_LIT:U+002C>')<EOL>for kwargs_item in kwargs_list:<EOL><INDENT>if '<STR_LIT:=>' in kwargs_item:<EOL><INDENT>k, v = kwargs_item.split('<STR_LIT:=>', <NUM_LIT:1>)<EOL>k = k.strip()<EOL>kwargs[k] = template.Variable(v)<EOL><DEDENT><DEDENT>return args, kwargs<EOL>
Parse uniformly args and kwargs from a templatetag

Usage::

  For parsing a template like this:

  {% footag my_contents,height=10,zoom=20 as myvar %}

  You simply do this:

  @register.tag
  def footag(parser, token):
      args, kwargs = parse_args_kwargs(parser, token)