parameters: (s, length=255, killwords=False, end='...')
return_statement: return result + end
docstring: Return a truncated copy of the string. The length is specified
      with the first parameter which defaults to ``255``. If the second
      parameter is ``true`` the filter will cut the text at length. Otherwise
      it will discard the last word. If the text was in fact
      truncated it will append an ellipsis sign (``"..."``). If you want a
      different ellipsis sign than ``"..."`` you can specify it using the
      third parameter.
  
      .. sourcecode:: jinja
  
          {{ "foo bar baz"|truncate(9) }}
              -> "foo ..."
          {{ "foo bar baz"|truncate(9, True) }}
              -> "foo ba..."
docstring_summary: Return a truncated copy of the string. The length is specified
      with the first parameter which defaults to ``255``. If the second
      parameter is ``true`` the filter will cut the text at length. Otherwise
      it will discard the last word. If the text was in fact
      truncated it will append an ellipsis sign (``"..."``). If you want a
      different ellipsis sign than ``"..."`` you can specify it using the
      third parameter.
docstring_tokens: Return a truncated copy of the string . The length is specified with the first parameter which defaults to 255 . If the second parameter is true the filter will cut the text at length . Otherwise it will discard the last word . If the text was in fact truncated it will append an ellipsis sign ( ... ) . If you want a different ellipsis sign than ... you can specify it using the third parameter .
function: def do_truncate(s, length=255, killwords=False, end='...'):
      """Return a truncated copy of the string. The length is specified
      with the first parameter which defaults to ``255``. If the second
      parameter is ``true`` the filter will cut the text at length. Otherwise
      it will discard the last word. If the text was in fact
      truncated it will append an ellipsis sign (``"..."``). If you want a
      different ellipsis sign than ``"..."`` you can specify it using the
      third parameter.
  
      .. sourcecode:: jinja
  
          {{ "foo bar baz"|truncate(9) }}
              -> "foo ..."
          {{ "foo bar baz"|truncate(9, True) }}
              -> "foo ba..."
  
      """
      if len(s) <= length:
          return s
      elif killwords:
          return s[:length - len(end)] + end
  
      result = s[:length - len(end)].rsplit(' ', 1)[0]
      if len(result) < length:
          result += ' '
      return result + end
function_tokens: def do_truncate ( s , length = 255 , killwords = False , end = '...' ) : if len ( s ) <= length : return s elif killwords : return s [ : length - len ( end ) ] + end result = s [ : length - len ( end ) ] . rsplit ( ' ' , 1 ) [ 0 ] if len ( result ) < length : result += ' ' return result + end