code: def ifposition(parser, token):
      
      bits = list(token.split_contents())
      end_tag = 'end' + bits[0]
  
      nofallback = False
      if bits[-1] == 'nofallback':
          nofallback = True
          bits.pop()
  
      if len(bits) >= 4 and bits[-2] == 'for':
          category = template.Variable(bits.pop())
          pos_names = bits[1:-1]
      else:
          raise TemplateSyntaxError('Invalid syntax: {% ifposition POSITION_NAME ... for CATEGORY [nofallback] %}')
  
      nodelist_true = parser.parse(('else', end_tag))
      token = parser.next_token()
  
      if token.contents == 'else':
          nodelist_false = parser.parse((end_tag,))
          parser.delete_first_token()
      else:
          nodelist_false = template.NodeList()
  
      return IfPositionNode(category, pos_names, nofallback, nodelist_true, nodelist_false)
docs: Syntax::
  
          {% ifposition POSITION_NAME ... for CATEGORY [nofallback] %}
          {% else %}
          {% endifposition %}