code: def boolean(value):
      '''
      Convert the content of a string (or a number) to a boolean.
      Do nothing when input value is already a boolean.
  
      This filter accepts usual values for ``True`` and ``False``:
      "0", "f", "false", "n", etc.
      '''
      if value is None or isinstance(value, bool):
          return value
  
      try:
          return bool(int(value))
      except ValueError:
          lower_value = value.strip().lower()
          if not lower_value:
              return None
          if lower_value in ('f', 'false', 'n', 'no', 'off'):
              return False
          if lower_value in ('on', 't', 'true', 'y', 'yes'):
              return True
          raise Invalid('Unable to parse boolean {0}'.format(value)f boolean(value):
      '''
      Convert the content of a string (or a number) to a boolean.
      Do nothing when input value is already a boolean.
  
      This filter accepts usual values for ``True`` and ``False``:
      "0", "f", "false", "n", etc.
      '''
      if value is None or isinstance(value, bool):
          return value
  
      try:
          return bool(int(value))
      except ValueError:
          lower_value = value.strip().lower()
          if not lower_value:
              return None
          if lower_value in ('f', 'false', 'n', 'no', 'off'):
              return False
          if lower_value in ('on', 't', 'true', 'y', 'yes'):
              return True
          raise Invalid('Unable to parse boolean {0}'.format(value))
docs: Convert the content of a string (or a number) to a boolean.
      Do nothing when input value is already a boolean.
  
      This filter accepts usual values for ``True`` and ``False``:
      "0", "f", "false", "n", etc.