fix: jinja complex type transforms doesn't work as documented (#80067)

jinja complex type transforms: dict(somelist| slice(2)) doesn't work as documented. Changed the example to use zip_longest
pull/80079/head
Desmond Obisi 2 years ago committed by GitHub
parent 940fdf5dba
commit 5ad77fc7bb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -230,7 +230,7 @@ These example produces ``{"a": "b", "c": "d"}``
vars:
single_list: [ 'a', 'b', 'c', 'd' ]
mydict: "{{ dict(single_list | slice(2)) }}"
mydict: "{{ dict(single_list[::2] | zip_longest(single_list[1::2])) }}"
.. code-block:: YAML+Jinja
@ -240,7 +240,7 @@ These example produces ``{"a": "b", "c": "d"}``
list_of_pairs: [ ['a', 'b'], ['c', 'd'] ]
mydict: "{{ dict(list_of_pairs) }}"
Both end up being the same thing, with ``slice(2)`` transforming ``single_list`` to a ``list_of_pairs`` generator.
Both end up being the same thing, with ``zip_longest`` transforming ``single_list`` to a ``list_of_pairs`` generator.

Loading…
Cancel
Save