code: def to_bool(val):
      '''
      Returns the logical value.
  
      .. code-block:: jinja
  
          {{ 'yes' | to_bool }}
  
      will be rendered as:
  
      .. code-block:: text
  
          True
      '''
      if val is None:
          return False
      if isinstance(val, bool):
          return val
      if isinstance(val, (six.text_type, six.string_types)):
          return val.lower() in ('yes', '1', 'true')
      if isinstance(val, six.integer_types):
          return val > 0
      if not isinstance(val, collections.Hashable):
          return bool(val)
      return Falsf to_bool(val):
      '''
      Returns the logical value.
  
      .. code-block:: jinja
  
          {{ 'yes' | to_bool }}
  
      will be rendered as:
  
      .. code-block:: text
  
          True
      '''
      if val is None:
          return False
      if isinstance(val, bool):
          return val
      if isinstance(val, (six.text_type, six.string_types)):
          return val.lower() in ('yes', '1', 'true')
      if isinstance(val, six.integer_types):
          return val > 0
      if not isinstance(val, collections.Hashable):
          return bool(val)
      return False
docs: Returns the logical value.
  
      .. code-block:: jinja
  
          {{ 'yes' | to_bool }}
  
      will be rendered as:
  
      .. code-block:: text
  
          True