mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02: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
10
.gitignore
vendored
10
.gitignore
vendored
|
@ -22,10 +22,10 @@ docs/man/man3/*
|
|||
*.sublime-project
|
||||
*.sublime-workspace
|
||||
# docsite stuff...
|
||||
docsite/rst/modules
|
||||
docsite/*.html
|
||||
docsite/_static/*.gif
|
||||
docsite/_static/*.png
|
||||
docsite/_static/websupport.js
|
||||
docsite/latest/rst/modules
|
||||
docsite/latest/*.html
|
||||
docsite/latest/_static/*.gif
|
||||
docsite/latest/_static/*.png
|
||||
docsite/latest/_static/websupport.js
|
||||
# deb building stuff...
|
||||
debian/
|
||||
|
|
14
Makefile
14
Makefile
|
@ -177,22 +177,8 @@ deb: debian
|
|||
modulepages:
|
||||
PYTHONPATH=./lib $(PYTHON) hacking/module_formatter.py -A $(VERSION) -t man -o docs/man/man3/ --module-dir=library --template-dir=hacking/templates
|
||||
|
||||
modulejson:
|
||||
mkdir -p docs/json
|
||||
PYTHONPATH=./lib $(PYTHON) hacking/module_formatter.py -A $(VERSION) -t json -o docs/json --module-dir=library --template-dir=hacking/templates
|
||||
|
||||
modulejs:
|
||||
mkdir -p docs/js
|
||||
make modulejson
|
||||
PYTHONPATH=./lib $(PYTHON) hacking/module_formatter.py -A $(VERSION) -t js -o docs/js --module-dir=docs/json --template-dir=hacking/templates
|
||||
|
||||
# because this requires Sphinx it is not run as part of every build, those building the RPM and so on can ignore this
|
||||
|
||||
webdocs:
|
||||
(cd docsite/latest; make docs)
|
||||
PYTHONPATH=./lib $(PYTHON) hacking/module_formatter.py -A $(VERSION) -t json -o docs/json --module-dir=library --template-dir=hacking/templates
|
||||
|
||||
modulejs: modulejson
|
||||
-(mkdir -p docs/json)
|
||||
PYTHONPATH=./lib $(PYTHON) hacking/module_formatter.py -A $(VERSION) -t js -o docs/json --module-dir=library --template-dir=hacking/templates
|
||||
|
||||
|
|
|
@ -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…
Reference in a new issue