Merge pull request #16272 from rallytime/bp-16252

Backport #16252 to 2014.7
This commit is contained in:
Nicole Thomas 2014-09-30 14:15:30 -06:00
commit de50067a91
2 changed files with 24 additions and 0 deletions

View File

@ -55,6 +55,19 @@ def wrap_tmpl_func(render_str):
# We want explicit context to overwrite the **kws # We want explicit context to overwrite the **kws
kws.update(context) kws.update(context)
context = kws context = kws
assert 'opts' in context
assert 'saltenv' in context
if 'sls' in context:
slspath = context['sls'].replace('.', '/')
if tmplpath is not None:
context['tplpath'] = tmplpath
if not tmplpath.lower().replace('\\', '/').endswith('/init.sls'):
slspath = os.path.dirname(slspath)
context['slsdotpath'] = slspath.replace('/', '.')
context['slscolonpath'] = slspath.replace('/', ':')
context['sls_path'] = slspath.replace('/', '_')
context['slspath'] = slspath
if isinstance(tmplsrc, string_types): if isinstance(tmplsrc, string_types):
if from_str: if from_str:

View File

@ -268,6 +268,17 @@ G:
list('ABCDEFG') list('ABCDEFG')
) )
def test_slsdir(self):
result = render_sls('''
formula/woot.sls:
cmd.run:
- name: echo {{ slspath }}
- cwd: /
''', sls='formula.woot', argline='yaml . jinja')
r = result['formula/woot.sls']['cmd.run'][0]['name']
self.assertEqual(r, 'echo formula/woot')
if __name__ == '__main__': if __name__ == '__main__':
from integration import run_tests from integration import run_tests