mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
Adds doc for new slice filter (#35904)
* Adds doc for new slice filter * Fixes example * Adds empty line * Moves documentation to other section and removes bad suggestion
This commit is contained in:
parent
0bd9b3019f
commit
3371a93b9e
1 changed files with 13 additions and 2 deletions
|
@ -904,6 +904,17 @@ To make use of one attribute from each item in a list of complex variables, use
|
|||
# get a comma-separated list of the mount points (e.g. "/,/mnt/stuff") on a host
|
||||
{{ ansible_mounts|map(attribute='mount')|join(',') }}
|
||||
|
||||
.. versionadded:: 2.5
|
||||
|
||||
The `slice` filter can be used to extract the values of specific keys from a
|
||||
hash::
|
||||
|
||||
{{ {'x': 1, 'y': 2, 'z': 3 } | slice(['x', 'z']) }}
|
||||
|
||||
This will result in::
|
||||
|
||||
[1, 2]
|
||||
|
||||
To get date object from string use the `to_datetime` filter, (new in version in 2.2)::
|
||||
|
||||
# get amount of seconds between two dates, default date format is %Y-%m-%d %H:%M:%S but you can pass your own one
|
||||
|
|
Loading…
Reference in a new issue