def if_pred(parser, token, predicate):
  bits = list(token.split_contents())
  if len(bits) != 3:
    raise template.TemplateSyntaxError, "%r takes two arguments" % bits[0]
  end_tag = 'end' + bits[0]
  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 IfPredNode(bits[1], bits[2], predicate, nodelist_true, nodelist_false)
dataset/ETHPy150Open CollabQ/CollabQ/common/templatetags/base.py/if_pred/original