Variable | register |
Undocumented |
Function | _property_resolver |
When arg is convertible to float, behave like operator.itemgetter(arg) Otherwise, chain __getitem__() and getattr(). |
Function | add |
Add the arg to the value. |
Function | addslashes |
Add slashes before quotes. Useful for escaping strings in CSV, for example. Less useful for escaping JavaScript; use the escapejs filter instead. |
Function | capfirst |
Capitalize the first character of the value. |
Function | center |
Center the value in a field of a given width. |
Function | cut |
Remove all values of arg from the given string. |
Function | date |
Format a date according to the given format. |
Function | default |
If value is unavailable, use given default. |
Function | default_if_none |
If value is None, use given default. |
Function | dictsort |
Given a list of dicts, return that list sorted by the property given in the argument. |
Function | dictsortreversed |
Given a list of dicts, return that list sorted in reverse order by the property given in the argument. |
Function | divisibleby |
Return True if the value is divisible by the argument. |
Function | escape_filter |
Mark the value as a string that should be auto-escaped. |
Function | escapejs_filter |
Hex encode characters for use in JavaScript strings. |
Function | filesizeformat |
Format the value like a 'human-readable' file size (i.e. 13 KB, 4.1 MB, 102 bytes, etc.). |
Function | first |
Return the first item in a list. |
Function | floatformat |
Display a float to a specified number of decimal places. |
Function | force_escape |
Escape a string's HTML. Return a new string containing the escaped characters (as opposed to "escape", which marks the content for later possible escaping). |
Function | get_digit |
No summary |
Function | iriencode |
Escape an IRI value for use in a URL. |
Function | join |
Join a list with a string, like Python's str.join(list). |
Function | json_script |
Output value JSON-encoded, wrapped in a <script type="application/json"> tag. |
Function | last |
Return the last item in a list. |
Function | length |
Return the length of the value - useful for lists. |
Function | length_is |
Return a boolean of whether the value's length is the argument. |
Function | linebreaks_filter |
Replace line breaks in plain text with appropriate HTML; a single newline becomes an HTML line break (<br>) and a new line followed by a blank line becomes a paragraph break (</p>). |
Function | linebreaksbr |
Convert all newlines in a piece of plain text to HTML line breaks (<br>). |
Function | linenumbers |
Display text with line numbers. |
Function | ljust |
Left-align the value in a field of a given width. |
Function | lower |
Convert a string into all lowercase. |
Function | make_list |
Return the value turned into a list. |
Function | phone2numeric_filter |
Take a phone number and converts it in to its numerical equivalent. |
Function | pluralize |
Return a plural suffix if the value is not 1, '1', or an object of length 1. By default, use 's' as the suffix: |
Function | pprint |
A wrapper around pprint.pprint -- for debugging, really. |
Function | random |
Return a random item from the list. |
Function | rjust |
Right-align the value in a field of a given width. |
Function | safe |
Mark the value as a string that should not be auto-escaped. |
Function | safeseq |
A "safe" filter for sequences. Mark each element in the sequence, individually, as safe, after converting them to strings. Return a list with the results. |
Function | slice_filter |
Return a slice of the list using the same syntax as Python's list slicing. |
Function | slugify |
Convert to ASCII. Convert spaces to hyphens. Remove characters that aren't alphanumerics, underscores, or hyphens. Convert to lowercase. Also strip leading and trailing whitespace. |
Function | stringfilter |
Decorator for filters which should only receive strings. The object passed as the first positional argument will be converted to a string. |
Function | stringformat |
Format the variable according to the arg, a string formatting specifier. |
Function | striptags |
Strip all [X]HTML tags. |
Function | time |
Format a time according to the given format. |
Function | timesince_filter |
Format a date as the time since that date (i.e. "4 days, 6 hours"). |
Function | timeuntil_filter |
Format a date as the time until that date (i.e. "4 days, 6 hours"). |
Function | title |
Convert a string into titlecase. |
Function | truncatechars |
Truncate a string after arg number of characters. |
Function | truncatechars_html |
Truncate HTML after arg number of chars. Preserve newlines in the HTML. |
Function | truncatewords |
Truncate a string after arg number of words. Remove newlines within the string. |
Function | truncatewords_html |
Truncate HTML after arg number of words. Preserve newlines in the HTML. |
Function | unordered_list |
Recursively take a self-nested list and return an HTML unordered list -- WITHOUT opening and closing <ul> tags. |
Function | upper |
Convert a string into all uppercase. |
Function | urlencode |
Escape a value for use in a URL. |
Function | urlize |
Convert URLs in plain text into clickable links. |
Function | urlizetrunc |
Convert URLs into clickable links, truncating URLs to the given character limit, and adding 'rel=nofollow' attribute to discourage spamming. |
Function | wordcount |
Return the number of words. |
Function | wordwrap |
Wrap words at arg line length. |
Function | yesno |
Given a string mapping values for true, false, and (optionally) None, return one of those strings according to the value: |
When arg is convertible to float, behave like operator.itemgetter(arg) Otherwise, chain __getitem__() and getattr().
>>> _property_resolver(1)('abc') 'b' >>> _property_resolver('1')('abc') Traceback (most recent call last): ... TypeError: string indices must be integers >>> class Foo: ... a = 42 ... b = 3.14 ... c = 'Hey!' >>> _property_resolver('b')(Foo()) 3.14
Display a float to a specified number of decimal places.
If called without an argument, display the floating point number with one decimal place -- but only if there's a decimal place to be displayed:
If arg is positive, always display exactly arg number of decimal places:
If arg is negative, display arg number of decimal places -- but only if there are places to be displayed:
If arg has the 'g' suffix, force the result to be grouped by the THOUSAND_SEPARATOR for the active locale. When the active locale is en (English):
If arg has the 'u' suffix, force the result to be unlocalized. When the active locale is pl (Polish):
If the input float is infinity or NaN, display the string representation of that value.
Return the value turned into a list.
For an integer, it's a list of digits. For a string, it's a list of characters.
Return a plural suffix if the value is not 1, '1', or an object of length 1. By default, use 's' as the suffix:
If an argument is provided, use that string instead:
If the provided argument contains a comma, use the text before the comma for the singular case and the text after the comma for the plural case:
Format the variable according to the arg, a string formatting specifier.
This specifier uses Python string formatting syntax, with the exception that the leading "%" is dropped.
See https://docs.python.org/library/stdtypes.html#printf-style-string-formatting for documentation of Python string formatting.
Recursively take a self-nested list and return an HTML unordered list -- WITHOUT opening and closing <ul> tags.
Assume the list is in the proper format. For example, if var contains: ['States', ['Kansas', ['Lawrence', 'Topeka'], 'Illinois']], then {{ var|unordered_list }} returns:
<li>States <ul> <li>Kansas <ul> <li>Lawrence</li> <li>Topeka</li> </ul> </li> <li>Illinois</li> </ul> </li>
Escape a value for use in a URL.
The safe parameter determines the characters which should not be escaped by Python's quote() function. If not provided, use the default safe characters (but an empty string can be provided when all characters should be escaped).
Convert URLs into clickable links, truncating URLs to the given character limit, and adding 'rel=nofollow' attribute to discourage spamming.
Argument: Length to truncate URLs to.
Given a string mapping values for true, false, and (optionally) None, return one of those strings according to the value:
Value | Argument | Outputs |
---|---|---|
True | "yeah,no,maybe" | yeah |
False | "yeah,no,maybe" | no |
None | "yeah,no,maybe" | maybe |
None | "yeah,no" | "no" (converts None to False if no mapping for None is given. |