Add expandvars jinja2 filter (#38805)

* Add expandvars jinja2 filter

* Add docs

* Minor edit
This commit is contained in:
Martin Krizek 2018-04-18 09:29:19 +02:00 committed by GitHub
parent 1cc2aeb40a
commit 8173602a34
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 0 deletions

View file

@ -895,6 +895,14 @@ To expand a path containing a tilde (`~`) character (new in version 1.5)::
{{ path | expanduser }} {{ path | expanduser }}
To expand a path containing environment variables::
{{ path | expandvars }}
.. note:: `expandvars` expands local variables; using it on remote paths can lead to errors.
.. versionadded:: 2.6
To get the real path of a link (new in version 1.8):: To get the real path of a link (new in version 1.8)::
{{ path | realpath }} {{ path | realpath }}

View file

@ -530,6 +530,7 @@ class FilterModule(object):
'basename': partial(unicode_wrap, os.path.basename), 'basename': partial(unicode_wrap, os.path.basename),
'dirname': partial(unicode_wrap, os.path.dirname), 'dirname': partial(unicode_wrap, os.path.dirname),
'expanduser': partial(unicode_wrap, os.path.expanduser), 'expanduser': partial(unicode_wrap, os.path.expanduser),
'expandvars': partial(unicode_wrap, os.path.expandvars),
'realpath': partial(unicode_wrap, os.path.realpath), 'realpath': partial(unicode_wrap, os.path.realpath),
'relpath': partial(unicode_wrap, os.path.relpath), 'relpath': partial(unicode_wrap, os.path.relpath),
'splitext': partial(unicode_wrap, os.path.splitext), 'splitext': partial(unicode_wrap, os.path.splitext),