mirror of
https://github.com/ansible-collections/community.general.git
synced 2026-05-07 13:52:54 +00:00
Add from_yaml_all to support multi document yaml strings (#43037)
* Support multi-doc yaml in the from_yaml filter * Most automatic method of handling multidoc * Only use safe_load_all * Implement separate filter * Update plugin docs and changelog
This commit is contained in:
committed by
Sam Doran
parent
19dc267e4c
commit
d27de6acd9
@@ -210,6 +210,12 @@ def from_yaml(data):
|
||||
return data
|
||||
|
||||
|
||||
def from_yaml_all(data):
|
||||
if isinstance(data, string_types):
|
||||
return yaml.safe_load_all(data)
|
||||
return data
|
||||
|
||||
|
||||
@environmentfilter
|
||||
def rand(environment, end, start=None, step=None, seed=None):
|
||||
if seed is None:
|
||||
@@ -600,6 +606,7 @@ class FilterModule(object):
|
||||
'to_yaml': to_yaml,
|
||||
'to_nice_yaml': to_nice_yaml,
|
||||
'from_yaml': from_yaml,
|
||||
'from_yaml_all': from_yaml_all,
|
||||
|
||||
# path
|
||||
'basename': partial(unicode_wrap, os.path.basename),
|
||||
|
||||
Reference in New Issue
Block a user