1
0
Fork 0
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:
Michael DeHaan 2013-04-12 18:38:48 -04:00
parent 687a68091f
commit 3f3b2a9448
3 changed files with 15 additions and 19 deletions

10
.gitignore vendored
View file

@ -22,10 +22,10 @@ docs/man/man3/*
*.sublime-project *.sublime-project
*.sublime-workspace *.sublime-workspace
# docsite stuff... # docsite stuff...
docsite/rst/modules docsite/latest/rst/modules
docsite/*.html docsite/latest/*.html
docsite/_static/*.gif docsite/latest/_static/*.gif
docsite/_static/*.png docsite/latest/_static/*.png
docsite/_static/websupport.js docsite/latest/_static/websupport.js
# deb building stuff... # deb building stuff...
debian/ debian/

View file

@ -177,22 +177,8 @@ deb: debian
modulepages: modulepages:
PYTHONPATH=./lib $(PYTHON) hacking/module_formatter.py -A $(VERSION) -t man -o docs/man/man3/ --module-dir=library --template-dir=hacking/templates 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 # because this requires Sphinx it is not run as part of every build, those building the RPM and so on can ignore this
webdocs: webdocs:
(cd docsite/latest; make docs) (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

View file

@ -432,9 +432,19 @@ def _get_filter_plugins():
return 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): def template_from_string(basedir, data, vars):
''' run a file through the (Jinja2) templating engine ''' ''' run a file through the (Jinja2) templating engine '''
data = _smush_braces(data)
try: try:
if type(data) == str: if type(data) == str:
data = unicode(data, 'utf-8') data = unicode(data, 'utf-8')