Merge pull request #11864 from jhawkesworth/win_path_filters
add win_basename and win_dirname filters
This commit is contained in:
commit
5027f66562
2 changed files with 11 additions and 0 deletions
|
@ -338,10 +338,18 @@ To get the last name of a file path, like 'foo.txt' out of '/etc/asdf/foo.txt'::
|
||||||
|
|
||||||
{{ path | basename }}
|
{{ path | basename }}
|
||||||
|
|
||||||
|
To get the last name of a windows style file path (new in version 2.0)::
|
||||||
|
|
||||||
|
{{ path | win_basename }}
|
||||||
|
|
||||||
To get the directory from a path::
|
To get the directory from a path::
|
||||||
|
|
||||||
{{ path | dirname }}
|
{{ path | dirname }}
|
||||||
|
|
||||||
|
To get the directory from a windows path (new version 2.0)::
|
||||||
|
|
||||||
|
{{ path | win_dirname }}
|
||||||
|
|
||||||
To expand a path containing a tilde (`~`) character (new in version 1.5)::
|
To expand a path containing a tilde (`~`) character (new in version 1.5)::
|
||||||
|
|
||||||
{{ path | expanduser }}
|
{{ path | expanduser }}
|
||||||
|
|
|
@ -21,6 +21,7 @@ import sys
|
||||||
import base64
|
import base64
|
||||||
import json
|
import json
|
||||||
import os.path
|
import os.path
|
||||||
|
import ntpath
|
||||||
import types
|
import types
|
||||||
import pipes
|
import pipes
|
||||||
import glob
|
import glob
|
||||||
|
@ -251,6 +252,8 @@ class FilterModule(object):
|
||||||
'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),
|
||||||
|
'win_basename': partial(unicode_wrap, ntpath.basename),
|
||||||
|
'win_dirname': partial(unicode_wrap, ntpath.dirname),
|
||||||
|
|
||||||
# value as boolean
|
# value as boolean
|
||||||
'bool': bool,
|
'bool': bool,
|
||||||
|
|
Loading…
Reference in a new issue