mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-04-26 12:21:26 -07:00
Add a new "contains" jinja2 test (#45798)
* Add contains jinja2 test * backticks
This commit is contained in:
parent
421d67f1ee
commit
f728f2bff0
3 changed files with 48 additions and 0 deletions
|
@ -36,6 +36,14 @@ def isnotanumber(x):
|
|||
return False
|
||||
|
||||
|
||||
def contains(seq, value):
|
||||
'''Opposite of the ``in`` test, allowing use as a test in filters like ``selectattr``
|
||||
|
||||
.. versionadded:: 2.8
|
||||
'''
|
||||
return value in seq
|
||||
|
||||
|
||||
class TestModule:
|
||||
''' Ansible math jinja2 tests '''
|
||||
|
||||
|
@ -46,6 +54,9 @@ class TestModule:
|
|||
'subset': issubset,
|
||||
'issuperset': issuperset,
|
||||
'superset': issuperset,
|
||||
'contains': contains,
|
||||
|
||||
# numbers
|
||||
'isnan': isnotanumber,
|
||||
'nan': isnotanumber,
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue