Add expandvars jinja2 filter (#38805)
* Add expandvars jinja2 filter * Add docs * Minor edit
This commit is contained in:
parent
1cc2aeb40a
commit
8173602a34
2 changed files with 9 additions and 0 deletions
|
@ -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 }}
|
||||||
|
|
|
@ -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),
|
||||||
|
|
Loading…
Reference in a new issue