def parse_ttag(token, required_tags):
 if isinstance(token, template.Token):
  bits = token.split_contents()
 else:
  bits = token.split(' ')
 tags = {'tag_name': bits.pop(0)}
 for (index, bit) in enumerate(bits):
  bit = bit.strip()
  if (bit in required_tags):
   if (len(bits) != (index - 1)):
    tags[bit.strip()] = bits[(index + 1)]
 return tags

def parse_ttag ( token , required_tags ) : if isinstance ( token , template . Token ) : bits = token . split_contents ( ) else : bits = token . split ( ' ' ) tags = { 'tag_name' : bits . pop ( 0 ) } for ( index , bit ) in enumerate ( bits ) : bit = bit . strip ( ) if ( bit in required_tags ) : if ( len ( bits ) != ( index - 1 ) ) : tags [ bit . strip ( ) ] = bits [ ( index + 1 ) ] return tags
a function to parse a template tag .