sum (iterable, attribute=None, start=0)Returns the sum of a sequence of numbers plus the value of parameter ‘start’ (which defaults to 0). When the sequence is empty it returns start. It is also possible to sum up only certain attributes: Total: {{ items|sum(attribute='price') }}
Changed in version 2.6: The attribute parameter was added to allow suming up over attributes. Also the start parameter was moved on to the right.
title (s)Return a titlecased version of the value. I.e. words will start with uppercase letters, all remaining characters are lowercase.
trim (value)Strip leading and trailing whitespace.
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. {{ "foo bar baz"|truncate(9) }}
-> "foo ..."
{{ "foo bar baz"|truncate(9, True) }}
-> "foo ba..."
upper (s)Convert a value to uppercase.
urlencode (value)Escape strings for use in URLs (uses UTF-8 encoding). It accepts both dictionaries and regular strings as well as pairwise iterables.
urlize (value, trim_url_limit=None, nofollow=False, target=None)Converts URLs in plain text into clickable links. If you pass the filter an additional integer it will shorten the urls to that number. Also a third argument exists that makes the urls “nofollow”: {{ mytext|urlize(40, true) }}
links are shortened to 40 chars and defined with rel="nofollow"
If target is specified, the target attribute will be added to the <a> tag: {{ mytext|urlize(40, target='_blank') }}
Changed in version 2.8+: The target parameter was added.
wordcount (s)Count the words in that string.
wordwrap (s, width=79, break_long_words=True, wrapstring=None)Return a copy of the string passed to the filter wrapped after 79 characters. You can override this default using the first parameter. If you set the second parameter to false Jinja will not split words apart if they are longer than width. By default, the newlines will be the default newlines for the environment, but this can be changed using the wrapstring keyword argument. New in version 2.7: Added support for the wrapstring parameter.
xmlattr (d, autospace=True)Create an SGML/XML attribute string based on the items in a dict. All values that are neither none nor undefined are automatically escaped: <ul{{ {'class': 'my_list', 'missing': none,
'id': 'list-%d'|format(variable)}|xmlattr }}>
...
</ul>
Results in something like this: <ul class="my_list" id="list-42">
...
</ul>
As you can see it automatically prepends a space in front of the item if the filter returned something unless the second parameter is false.
|