@register.filter(is_safe=False)
def yesno(value, arg=None):
 if (arg is None):
  arg = ugettext(u'yes,no,maybe')
 bits = arg.split(u',')
 if (len(bits) < 2):
  return value
 try:
  (yes, no, maybe) = bits
 except ValueError:
  (yes, no, maybe) = (bits[0], bits[1], bits[1])
 if (value is None):
  return maybe
 if value:
  return yes
 return no

@ register . filter ( is_safe = False ) def yesno ( value , arg = None ) : if ( arg is None ) : arg = ugettext ( u'yes,no,maybe' ) bits = arg . split ( u',' ) if ( len ( bits ) < 2 ) : return value try : ( yes , no , maybe ) = bits except ValueError : ( yes , no , maybe ) = ( bits [ 0 ] , bits [ 1 ] , bits [ 1 ] ) if ( value is None ) : return maybe if value : return yes return no
given a string mapping values for true .