summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDesmond Obisi <51109125+DesmondSanctity@users.noreply.github.com>2023-02-23 16:27:17 +0100
committerGitHub <noreply@github.com>2023-02-23 10:27:17 -0500
commit5ad77fc7bb529d9733a17c1ef5d24a84b98f50d3 (patch)
tree94d9c55a48e7976b1456f57a05373e2d0ef89af2
parent940fdf5dba268c65859d5c55ab554f735467474e (diff)
downloadansible-5ad77fc7bb529d9733a17c1ef5d24a84b98f50d3.tar.gz
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
-rw-r--r--docs/docsite/rst/playbook_guide/complex_data_manipulation.rst4
1 files changed, 2 insertions, 2 deletions
diff --git a/docs/docsite/rst/playbook_guide/complex_data_manipulation.rst b/docs/docsite/rst/playbook_guide/complex_data_manipulation.rst
index 11ed3c388e..e7d23b336f 100644
--- a/docs/docsite/rst/playbook_guide/complex_data_manipulation.rst
+++ b/docs/docsite/rst/playbook_guide/complex_data_manipulation.rst
@@ -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.