List of Jinja Filters

When using Jinja, you have access to a number of filters to organize your data. In any Jinja editor on the platform, you can see what's available by using the | character within {{ }}

Here is everything available:

FunctionDescription

abs

Return the absolute value of the argument.

all

Return :py:data:True if none of the elements of the (async) iterable are false.

any

Return :py:data:False if none of the elements of the (async) iterable are true.

as_timezone

Return a string representation of a datetime in a particular format. dt: The inputted datetime object. If a string is passed, it will be parsed into a datetime timezone: The timezone to convert the datetime to. This can be a timezone name from the IANA db (e.g. 'America/New_York') There is a corresponding action in the 'transforms' pack that uses this filter - convert_datetime_to_timezone filter_objective: Convert a datetime object to a different timezone.

attr

Get an attribute of an object. foo

base64

Encode a string in base64. urlsafe: Whether to return a URL-safe base64 format. '-' is used instead of '+', and '_' instead of '/'.

basename

A filter to get the last name of a windows style file path.

batch

A filter that batches items. It works pretty much like slice but the other way round. It returns a list of lists with the given number of items. If you provide a second parameter this is used to fill up missing items.

capitalize

Capitalize a value. The first character will be uppercase, all others lowercase.

center

Centers the value in a field of a given width.

combine

Based on the Ansible combine filter, this filter allows hashes to be merged. For example, the following would override keys in one hash:

{{ {'a':1, 'b':2} | combine({'b':3}) }} The resulting hash would be: {'a':1, 'b': 3}

Parameters:

  • recursive:

    • False: Only the top level keys are merged (default)

    • True: Recursively merge dictionaries including nested dictionaries

  • list_merge:

    • replace: Replace lists with the new value by overwriting (default)

    • append: Append the new value to the older one

    • append_rp: Append newer values to the older one, but overwrite duplicates

    • keep: Keep the older value, discard the new value

    • prepend: Add new values in front of the older one

    • prepend_rp: Add newer values in front of the older one, but discard duplicates

Other examples:

{{ {'a':1, 'b': {'c':2} } | combine({'b': {'d': 3} }, recursive=False) }}The resulting hash would be: {'a': 1, 'b': {'d':3}}

{{ {'a':1, 'b':2} | combine({'b':3} list_merge='keep') }}The resulting hash would be: {'a':1, 'b':2}

convert_from_epoch

Convert an epoch timestamp to a datetime object convert_from_epoch(1549892280) datetime.datetime(2019, 2, 11, 13, 38)

count

Return the number of items in a container.

csv

Dump a list of rows (as dicts, or lists) to CSV format fieldnames: Controls which keys in each dict to include in CSV output. If rows are expressed as lists of strings instead of dicts, fieldnames will be emitted as the first row (i.e. column headers). writeheader: Whether to write the fieldnames as the first row in the CSV file delimiter: Delimiter separating values in the CSV file quotechar: Character used to enclose values in the CSV file escapechar: Character used to escape embedded quotechars within values doublequote: If True, two consecutive quotes are interpreted as one skipinitialspace: Whether to ignore whitespace immediately following delimiters, or to treat them as part of the value lineterminator: The character sequence which terminates rows quoting: Controls when quotes should be generated

d

If the value is undefined it will return the passed default value, otherwise the value of the variable. This will output the value of my_variable if the variable was defined, otherwise 'my_variable is not defined'. If you want to use default with variables that evaluate to false you have to set the second parameter to true. versionchanged:: 2.11 It's now possible to configure the :class:~jinja2.Environment with :class:~jinja2.ChainableUndefined to make the default filter work on nested elements and attributes that may contain undefined values in the chain without getting an :exc:~jinja2.UndefinedError.

datedelta

Add or subtract a number of years, months, weeks, or days from a datetime value: The inputted datetime object. If a string is passed, it will be parsed into a datetime years: Number of years to add or subtract from the datetime months: Number of months to add or subtract from the datetime weeks: Number of weeks to add or subtract from the datetime days: Number of days to add or subtract from the datetime hours: Number of hours to add or subtract from the datetime minutes: Number of minutes to add or subtract from the datetime seconds: Number of seconds to add or subtract from the datetime microseconds: Number of microseconds to add or subtract from the datetime day: The day of the month to set the datetime to. If the day is not valid for the month, the last day of the month is used. weekday: The day of the week to return. The value can be an integer (0-6) or a string (e.g. 'monday', 'tuesday', etc.) If the input string is not all lowercase, it will be converted to lowercase. When used in conjuctgin with the day parameter, the day parameter will be used to determine the week of the month. For example, if day=1 and weekday='monday', the first monday of the month will be returned. The math logic is a bit odd and can be reviewed in the tests. All 1st days of the week are in the 1-7 range, 2nd days of the week are in the 8-14 range, 3rd days of the week are in the 15-21 range, 4th days of the week are in the 22-28 range, 5th days of the week are in the 29-31 range. See doctests for more examples. datedelta('2020-01-01', days=1) datetime.datetime(2020, 1, 2, 0, 0)

default

If the value is undefined it will return the passed default value, otherwise the value of the variable. This will output the value of my_variable if the variable was defined, otherwise 'my_variable is not defined'. If you want to use default with variables that evaluate to false you have to set the second parameter to true. versionchanged:: 2.11 It's now possible to configure the :class:~jinja2.Environment with :class:~jinja2.ChainableUndefined to make the default filter work on nested elements and attributes that may contain undefined values in the chain without getting an :exc:~jinja2.UndefinedError.

dict

This filter transforms lists into dictionaries.

dictsort

Sort a dict and yield (key, value) pairs. Python dicts may not be in the order you want to display them in, so sort them first.

dirname

To get the directory from a path.

e

Replace the characters &, <, >, ', and " in the string with HTML-safe sequences. Use this if you need to display text that might contain such characters in HTML. If the object has an html method, it is called and the return value is assumed to already be safe for HTML. s: An object to be converted to a string and escaped. :return: A :class:Markup string with the escaped text.

enumerate

An async iterator of running count and element in an (async) iterable The count begins at start for the first element of iterable, and is incremented by 1 for each further element. The iterable may be a regular or async iterable.

escape

Replace the characters &, <, >, ', and " in the string with HTML-safe sequences. Use this if you need to display text that might contain such characters in HTML. If the object has an html method, it is called and the return value is assumed to already be safe for HTML. s: An object to be converted to a string and escaped. :return: A :class:Markup string with the escaped text.

filesizeformat

Format the value like a 'human-readable' file size (i.e. 13 kB, 4.1 MB, 102 Bytes, etc). Per default decimal prefixes are used (Mega, Giga, etc.), if the second parameter is set to True the binary prefixes are used (Mebi, Gibi).

first

Return the first item of a sequence.

flatten

Flatten a list of lists. lst: The inputted list to flatten. If the input is not a list, it will raise an error.

float

Convert the value into a floating point number. If the conversion doesn't work it will return 0.0. You can override this default using the first parameter.

forceescape

Enforce HTML escaping. This will probably double escape variables.

format

Apply the given values to a printf-style_ format string, like string % values. In most cases, it should be more convenient and efficient to use the % operator or :meth:str.format. _printf-style: https://docs.python.org/library/stdtypes.html

format_datetime

Return a string representation of a datetime in a particular format. output_format: The strftime datetime format specification to output datetime string in.

from_json_string

Deserialize from a JSON-serialized string

from_yaml_string

Deserialize from a YAML-serialized string

groupby

Group a sequence of objects by an attribute using Python's :func:itertools.groupby. The attribute can use dot notation for nested access, like "address.city". Unlike Python's groupby, the values are sorted first so only one group is returned for each unique value. For example, a list of User objects with a city attribute can be rendered in groups. In this example, grouper refers to the city value of the group. groupby yields namedtuples of (grouper, list), which can be used instead of the tuple unpacking above. grouper is the value of the attribute, and list is the items with that value. You can specify a default value to use if an object in the list does not have the given attribute. Like the :func:~jinja-filters.sort filter, sorting and grouping is case-insensitive by default. The key for each group will have the case of the first item in that group of values. For example, if a list of users has cities ["CA", "NY", "ca"], the "CA" group will have two values. This can be disabled by passing case_sensitive=True. versionchanged:: 3.1 Added the case_sensitive parameter. Sorting and grouping is case-insensitive by default, matching other filters that do comparisons. versionchanged:: 3.0 Added the default parameter. versionchanged:: 2.6 The attribute supports dot notation for nested access.

hmac

Return the bytes digest of the HMAC.

Usage:

{{ 'my_msg' | hmac('sha256', 'my key') }}

or

{{ 'my_msg' | hmac.sha256('my key') }}

returns

b'g\x98r\t\xff\x9c\xe3\x1b\x06\x00\xa8\xd4\\\x9aK4\xda\xf1\xe1n\xcc\xe4\x8f\x7f\x0bZJ4\xf1G\xfd\x89'

algorithm: one of the following supported hashing algorithms.

  • md5

  • sha1

  • shake_128

  • blake2s

  • sha3_256

  • sha512

  • sha3_512

  • shake_256

  • sha256

  • sha3_224

  • blake2b

  • sha224

  • sha384

  • sha3_384

key: The shared secret used to calculate the HMAC digest and authenticate the message. The security and strength of the HMAC depend on the secrecy and complexity of the key.

hex

Returns hex representations of bytes objects and UTF-8 strings. Usage: {{ 'my_msg' | hex }} returns 6d795f6d7367

indent

Return a copy of the string with each line indented by 4 spaces. The first line and blank lines are not indented by default. width: Number of spaces, or a string, to indent by. first: Don't skip indenting the first line. blank: Don't skip indenting empty lines. versionchanged:: 3.0 width can be a string. versionchanged:: 2.10 Blank lines are not indented by default.

int

Convert the value into an integer. If the conversion doesn't work it will return 0. You can override this default using the first parameter. You can also override the default base (10) in the second parameter, which handles input with prefixes such as 0b, 0o and 0x for bases 2, 8 and 16 respectively. The base is ignored for decimal numbers and non-string values.

items

Return an iterator over the (key, value) items of a mapping.

join

Return a string which is the concatenation of the strings in the sequence. The separator between elements is an empty string per default, you can define it with the optional parameter. It is also possible to join certain attributes of an object. versionadded:: 2.6 The attribute parameter was added.

json

Parse a JSON-serialized string

json_dump

Serialize value to JSON

json_escape

Add escape sequences to problematic characters in the string This filter simply passes the value to json.dumps as a convenient way of escaping characters in it, then strips the enclosing double-quotes.

json_parse

Deserialize from a JSON-serialized string

json_stringify

Serialize value to JSON

jsonpath_query

Extracts data from an object value using a JSONPath query. πŸ”— https://github.com/h2non/jsonpath-ng

last

Return the last item of a sequence. Note: Does not work with generators. You may want to explicitly convert it to a list.

length

Return the number of items in a container.

list

Create a :py:class:list from an (async) iterable. This is equivalent to [element async for element in iterable].

load_datetime

Parse a datetime string with a known format specification. date_format: The strftime datetime format specification to use in parsing. If not specified, datetime string is assumed to be in Python-flavored ISO8601 format.

lower

Convert a value to lowercase.

map

Applies a filter on a sequence of objects or looks up an attribute. This is useful when dealing with lists of objects but you are really only interested in a certain value of it. The basic usage is mapping on an attribute. Imagine you have a list of users but you are only interested in a list of usernames: You can specify a default value to use if an object in the list does not have the given attribute. Alternatively you can let it invoke a filter by passing the name of the filter and the arguments afterwards. A good example would be applying a text conversion filter on a sequence: Similar to a generator comprehension such as: versionchanged:: 2.11.0 Added the default parameter. versionadded:: 2.7

max

Return the largest item from an (async) iterable or from two or more values :raises ValueError: if iterable is empty and default is not set The key argument specifies a one-argument ordering function like that used for :py:meth:list.sort. It may be a regular or async callable and defaults to the identity function. The default argument specifies an object to return if the provided iterable is empty. If the iterable is empty and default is not provided, a :py:exc:ValueError is raised.

min

Return the smallest item from an (async) iterable or from two or more values :raises ValueError: if iterable is empty and default is not set The key argument specifies a one-argument ordering function like that used for :py:meth:list.sort. It may be a regular or async callable and defaults to the identity function. The default argument specifies an object to return if the provided iterable is empty. If the iterable is empty and default is not provided, a :py:exc:ValueError is raised.

parse_csv

Parse a CSV string into a list of dicts, with column headers as keys A list of list of strings (i.e. a collection of rows, each row containing column values) may be passed instead of a CSV. fieldnames: Names of each column to be used as keys in each row dict. If the first row of the CSV file is not the header, this parameter may be used to specify column names. restkey: If a row is missing values for columns, the list of missing column names will be placed under this key in the row dict. restval: If a row has more values than declared columns, the extra values will be placed under this key in the row dict. delimiter: Delimiter separating values in the CSV file quotechar: Character used to enclose values in the CSV file escapechar: Character used to escape embedded quotechars within values doublequote: If True, two consecutive quotes are interpreted as one skipinitialspace: Whether to ignore whitespace immediately following delimiters, or to treat them as part of the value lineterminator: The character sequence which terminates rows

parse_datetime

Parse a datetime string without knowing its format specification. This method of parsing is more lenient than load_datetime dayfirst: Whether to interpret the first value in an ambiguous 3-integer date (e.g. 01/05/09) as the day (True) or month (False). If yearfirst is set to True, this distinguishes between YDM and YMD. If set to None, this value is retrieved from the current :class:parserinfo object (which itself defaults to False). yearfirst: Whether to interpret the first value in an ambiguous 3-integer date (e.g. 01/05/09) as the year. If True, the first number is taken to be the year, otherwise the last number is taken to be the year. If this is set to None, the value is retrieved from the current :class:parserinfo object (which itself defaults to False). fuzzy: Whether to allow fuzzy parsing, allowing for string like "Today is January 1, 2047 at 8:21:00AM". ignoretz: If set True, time zones in parsed strings are ignored and a naive :class:datetime object is returned.

pprint

Pretty print a variable. Useful for debugging.

random

Return a random item from the sequence.

reduce

Reduce an (async) iterable by cumulative application of an (async) function. :raises TypeError: if iterable is empty and initial is not given Applies the function from the beginning of iterable, as if executing await function(current, anext(iterable)) until iterable is exhausted. Note that the output of function should be valid as its first input. The optional initial is prepended to all items of iterable when applying function. If the combination of initial and iterable contains exactly one item, it is returned without calling function.

regex_findall

To occurrences of regex matches in a string, use the regex_findall filter.

regex_match

This function is used to determine if a string matches a particular pattern. It takes three parameters: * value: This is the string to be matched. * pattern: This is the regular expression pattern to match against. * ignorecase: This is a boolean value to decide whether to ignore the case of the characters while matching. It first checks whether value is a string or not. If it's not, it converts value to a string. Then it uses the _get_regex_flags function (which is not defined in the provided code) to set the regular expression flags based on the ignorecase parameter. The function re.match() is then used to check if the pattern matches the beginning of the value. The result is converted to a boolean and returned.

regex_replace

To replace text in a string with regex, use the regex_replace filter.

regex_search

To search in a string with a regular expression and detect matches within a string, use the regex_search filter. It will return a boolean (true/false) if the defined regex exists within the string.

regex_substring

This function is used to find all the substrings in a string that match a particular pattern and return the substring at a specific index. It takes four parameters: * value: This is the string to be searched. * pattern: This is the regular expression pattern to match against. * result_index: This is the index of the substring to return after all the matches are found. * ignorecase: This is a boolean value to decide whether to ignore the case of the characters while matching. Similar to the regex_match function, it checks whether value is a string or not. If it's not, it converts value to a string. Then it uses the _get_regex_flags function to set the regular expression flags based on the ignorecase parameter. The function re.findall() is then used to find all the substrings in value that match the pattern. The substring at the result_index position is then returned. Note that if result_index is out of range (larger than the number of matches), the function will throw an IndexError.

reject

Filters a sequence of objects by applying a test to each object, and rejecting the objects with the test succeeding. If no test is specified, each object will be evaluated as a boolean. versionadded:: 2.7

rejectattr

Filters a sequence of objects by applying a test to the specified attribute of each object, and rejecting the objects with the test succeeding. If no test is specified, the attribute's value will be evaluated as a boolean. Similar to a generator comprehension such as: versionadded:: 2.7

replace

Return a copy of the value with all occurrences of a substring replaced with a new one. The first argument is the substring that should be replaced, the second is the replacement string. If the optional third argument count is given, only the first count occurrences are replaced.

reverse

Reverse the object or return an iterator that iterates over it the other way round.

round

Round the number to a given precision. The first parameter specifies the precision (default is 0), the second the rounding method: * 'common' rounds either up or down * 'ceil' always rounds up * 'floor' always rounds down If you don't specify a method 'common' is used. Note that even if rounded to 0 precision, a float is returned. If you need a real integer, pipe it through int.

safe

Mark the value as safe which means that in an environment with automatic escaping enabled this variable will not be escaped.

select

Filters a sequence of objects by applying a test to each object, and only selecting the objects with the test succeeding. If no test is specified, each object will be evaluated as a boolean. Similar to a generator comprehension such as: versionadded:: 2.7

selectattr

Filters a sequence of objects by applying a test to the specified attribute of each object, and only selecting the objects with the test succeeding. If no test is specified, the attribute's value will be evaluated as a boolean. Similar to a generator comprehension such as: versionadded:: 2.7

set

Create a :py:class:set from an (async) iterable This is equivalent to {element async for element in iterable}.

slice

Slice an iterator and return a list of lists containing those items. Useful if you want to create a div containing three ul tags that represent columns: .. sourcecode:: html+jinja If you pass it a second argument it's used to fill missing values on the last iteration.

sort

Sort an iterable using Python's :func:sorted.:param reverse: Sort descending instead of ascending. :param case_sensitive: When sorting strings, sort upper and lower case separately. :param attribute: When sorting objects or dicts, an attribute or key to sort by. Can use dot notation like "address.city". Can be a list of attributes like "age,name". The sort is stable, it does not change the relative order of elements that compare equal. This makes it is possible to chain sorts on different attributes and ordering. <div data-gb-custom-block data-tag="for" data-0=')

string

Convert an object to a string if it isn't already. This preserves a :class:Markup string rather than converting it back to a basic string, so it will still be marked as safe and won't be escaped again. value = escape("<User 1>") value Markup('<User 1>') escape(str(value)) Markup('&lt;User 1&gt;') escape(soft_str(value)) Markup('<User 1>')

striptags

Strip SGML/XML tags and replace adjacent whitespace by one space.

sum

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: .. versionchanged:: 2.6 The attribute parameter was added to allow summing up over attributes. Also the start parameter was moved on to the right.

time_delta

Add a duration of time to a datetime Use negative values to subtract durations of time instead.

title

Return a titlecased version of the value. I.e. words will start with uppercase letters, all remaining characters are lowercase.

to_ascii

Transliterate a Unicode object into an ASCII string errors specifies what to do with characters that have not been found in replacement tables. The default is 'ignore' which ignores the character. 'strict' raises an UnidecodeError. 'replace' substitutes the character with replace_str (default is '?'). 'preserve' keeps the original character. Note that if 'preserve' is used the returned string might not be ASCII!

to_human_time_from_seconds

Given a time value in seconds, this function returns a fuzzy version like 3m5s. :param seconds: Time specified in seconds. :type seconds: int or long or float :rtype: str

to_json_string

Serialize value to JSON

to_yaml_string

Serialize to YAML :param indent: Number of spaces to use for indentation :param sort_keys: Whether to sort mapping keys, or leave as-is

tojson

Serialize an object to a string of JSON, and mark it safe to render in HTML. This filter is only for use in HTML documents. The returned string is safe to render in HTML documents and <script> tags. The exception is in HTML attributes that are double-quoted. Use single quotes.

trim

Strip leading and trailing characters, by default whitespace.

truncate

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. Strings that only exceed the length by the tolerance margin given in the fourth parameter will not be truncated. The default leeway on newer Jinja versions is 5 and was 0 before but can be reconfigured globally.

tuple

Create a :py:class:tuple from an (async) iterable

unidecode

Transliterate a Unicode object into an ASCII string errors specifies what to do with characters that have not been found in replacement tables. The default is 'ignore' which ignores the character. 'strict' raises an UnidecodeError. 'replace' substitutes the character with replace_str (default is '?'). 'preserve' keeps the original character. Note that if 'preserve' is used the returned string might not be ASCII!

unique

Returns a list of unique items from the given iterable. The unique items are yielded in the same order as their first occurrence in the iterable passed to the filter. :param case_sensitive: Treat upper and lower case strings as distinct. :param attribute: Filter objects with unique values for this attribute.

upper

Convert a value to uppercase.

urlencode

Quote data for use in a URL path or query using UTF-8. Basic wrapper around :func:urllib.parse.quote when given a string, or :func:urllib.parse.urlencode for a dict or iterable. :param value: Data to quote. A string will be quoted directly. A dict or iterable of (key, value) pairs will be joined as a query string. When given a string, "/" is not quoted. HTTP servers treat "/" and "%2F" equivalently in paths.

urlize

Convert URLs in text into clickable links. This may not recognize links in some situations. Usually, a more comprehensive formatter, such as a Markdown library, is a better choice. Works on http://, https://, www., mailto:, and email addresses. Links with trailing punctuation (periods, commas, closing parentheses) and leading punctuation (opening parentheses) are recognized excluding the punctuation. Email addresses that include header fields are not recognized (for example, mailto:address@example.com?cc=copy@example.com). :param value: Original text containing URLs to link. :param trim_url_limit: Shorten displayed URL values to this length. :param nofollow: Add the rel=nofollow attribute to links. :param target: Add the target attribute to links. :param rel: Add the rel attribute to links. :param extra_schemes: Recognize URLs that start with these schemes in addition to the default behavior. Defaults to env.policies["urlize.extra_schemes"], which defaults to no extra schemes. .. versionchanged:: 3.0 The extra_schemes parameter was added. .. versionchanged:: 3.0 Generate https:// links for URLs without a scheme. .. versionchanged:: 3.0 The parsing rules were updated. Recognize email addresses with or without the mailto: scheme. Validate IP addresses. Ignore parentheses and brackets in more cases. .. versionchanged:: 2.8 The target parameter was added.

use_none

Convert a None value to a magic string preserving the None value when passed to actions

version_bump_major

This function increments the major version component of a version number (value) following semantic versioning rules. It returns the updated version number.

version_bump_minor

This function increments the minor version component of a version number (value) following semantic versioning rules. It returns the updated version number.

version_bump_patch

This function increments the patch version component of a version number (value) following semantic versioning rules. It returns the updated version number.

version_compare

This function compares two version numbers (value and pattern) using the semantic versioning rules provided by the semver library. It returns an integer value indicating the result of the comparison: * Returns 0 if value and pattern are equal. * Returns 1 if value is greater than pattern. * Returns -1 if value is less than pattern.

version_equal

This function compares two version numbers (value and pattern) and returns a boolean value indicating whether value is equal to pattern. It uses the version_compare function internally and checks if the comparison result is 0.

version_less_than

This function compares two version numbers (value and pattern) and returns a boolean value indicating whether value is less than pattern. It uses the version_compare function internally and checks if the comparison result is -1.

version_match

This function checks if a version number (value) matches a version range (pattern) using the semantic versioning rules provided by the semver library. It returns a boolean value indicating whether the version number matches the range.

version_more_than

This function compares two version numbers (value and pattern) and returns a boolean value indicating whether value is greater than pattern. It uses the version_compare function internally and checks if the comparison result is 1.

version_strip_patch

This function removes the patch version component from a version number (value). It returns a string representing the version number without the patch component.

wordcount

Count the words in that string.

wordwrap

Wrap a string to the given width. Existing newlines are treated as paragraphs to be wrapped separately. :param s: Original text to wrap. :param width: Maximum length of wrapped lines. :param break_long_words: If a word is longer than width, break it across lines. :param break_on_hyphens: If a word contains hyphens, it may be split across lines. :param wrapstring: String to join each wrapped line. Defaults to :attr:Environment.newline_sequence. .. versionchanged:: 2.11 Existing newlines are treated as paragraphs wrapped separately. .. versionchanged:: 2.11 Added the break_on_hyphens parameter. .. version changed:: 2.7 Added the wrapstring parameter.

wrap_text

Take a text string and wrap it to a specified width. The resulting string will be the original text except with newlines inserted so that no line is wider than the specified width. The default width is 70 characters. Raises: TypeError: If text is not a string TypeError: If width is not an integer wrap_text('Vero aliquam debitis. Reiciendis commodi dol', width=20) 'Vero aliquam\ndebitis. Reiciendis\ncommodi dol'

xmlattr

Create an SGML/XML attribute string based on the items in a dict. All values that are neither none nor undefined are automatically escaped: .. sourcecode:: html+jinja Results in something like this: .. sourcecode:: html 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.

yaml_dump

Serialize to YAML :param indent: Number of spaces to use for indentation :param sort_keys: Whether to sort mapping keys, or leave as-is

yaml_parse

Deserialize from a YAML-serialized string

zip

Return a list of tuples where the i-th element comes from the i-th list arg. If a list is exhausted before the others, the value of pad will be used in the tuple.

Last updated