mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-08-22 14:01:42 -07:00
Improve variable smushing so it only has to be done in one place. This is related to shlex.split being called
on untemplated variables in some rare cases.
This commit is contained in:
parent
af2fb56a10
commit
6fdfbb1a34
5 changed files with 27 additions and 18 deletions
|
@ -437,19 +437,9 @@ def template_from_file(basedir, path, vars):
|
|||
res = res + '\n'
|
||||
return template(basedir, res, vars)
|
||||
|
||||
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