From 4a6b5c5de2814e214d0bc73bc36e87008315f6ef Mon Sep 17 00:00:00 2001 From: Stijn Opheide Date: Mon, 8 Oct 2012 08:56:57 +0200 Subject: [PATCH] relative paths for (include/extends) in jinja2 templates --- .gitignore | 3 +++ lib/ansible/utils.py | 3 ++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index 3fc174d9c11..6174ca4cf23 100644 --- a/.gitignore +++ b/.gitignore @@ -14,3 +14,6 @@ rpm-build .idea # Mac OS X stuff .DS_Store +# Sublime stuff +*.sublime-project +*.sublime-workspace diff --git a/lib/ansible/utils.py b/lib/ansible/utils.py index 6c7a89462f7..5fb32e2ac3a 100644 --- a/lib/ansible/utils.py +++ b/lib/ansible/utils.py @@ -392,7 +392,8 @@ def template_from_file(basedir, path, vars): ''' run a file through the templating engine ''' realpath = path_dwim(basedir, path) - environment = jinja2.Environment(loader=jinja2.FileSystemLoader(basedir), trim_blocks=True) + loader=jinja2.FileSystemLoader([basedir,os.path.dirname(realpath)]) + environment = jinja2.Environment(loader=loader, trim_blocks=True) environment.filters['to_json'] = json.dumps environment.filters['from_json'] = json.loads environment.filters['to_yaml'] = yaml.dump