Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(tpldata): provide tplroot #51814

Merged
merged 4 commits into from
Jun 20, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions salt/modules/file.py
Original file line number Diff line number Diff line change
Expand Up @@ -6733,7 +6733,7 @@ def normpath(path):

.. code-block:: jinja

{%- from salt['file.normpath'](tpldir + '/../vars.jinja') import parent_vars %}
{%- from salt['file.normpath'](tpldir ~ '/../vars.jinja') import parent_vars %}

CLI Example:

Expand Down Expand Up @@ -6775,7 +6775,7 @@ def dirname(path):

.. code-block:: jinja

{%- from salt['file.dirname'](tpldir) + '/vars.jinja' import parent_vars %}
{%- from salt['file.dirname'](tpldir) ~ '/vars.jinja' import parent_vars %}

CLI Example:

Expand Down
1 change: 1 addition & 0 deletions salt/utils/jinja.py
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,7 @@ def get_source(self, environment, template):
'tplfile': tplfile,
'tpldir': '.' if tpldir == '' else tpldir,
'tpldot': tpldir.replace('/', '.'),
'tplroot': tpldir.split('/')[0],
}
environment.globals.update(tpldata)

Expand Down
1 change: 1 addition & 0 deletions salt/utils/templates.py
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,7 @@ def render_tmpl(tmplsrc,
'tplfile': template,
'tpldir': '.' if tpldir == '' else tpldir,
'tpldot': tpldir.replace('/', '.'),
'tplroot': tpldir.split('/')[0],
}
context.update(tpldata)
context['slsdotpath'] = slspath.replace('/', '.')
Expand Down