mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-07-23 05:10:22 -07:00
Smush Jinja2 braces in playbooks so unresolved variables get parsed nicely
This commit is contained in:
parent
687a68091f
commit
3f3b2a9448
3 changed files with 15 additions and 19 deletions
|
@ -432,9 +432,19 @@ def _get_filter_plugins():
|
|||
return FILTER_PLUGINS
|
||||
|
||||
|
||||
def _smush_braces(data):
|
||||
''' smush Jinaj2 braces so unresolved templates like {{ foo }} don't get parsed weird by key=value code '''
|
||||
while data.find('{{ ') != -1:
|
||||
data = data.replace('{{ ', '{{')
|
||||
while data.find(' }}') != -1:
|
||||
data = data.replace(' }}', '}}')
|
||||
return data
|
||||
|
||||
def template_from_string(basedir, data, vars):
|
||||
''' run a file through the (Jinja2) templating engine '''
|
||||
|
||||
data = _smush_braces(data)
|
||||
|
||||
try:
|
||||
if type(data) == str:
|
||||
data = unicode(data, 'utf-8')
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue