Correct splitext() description, and example (#74377)

`splitext()` returns a 2-tuple of strings, and the last element of the return value includes the `.`
pull/74393/head
Alex Willmer 4 years ago committed by GitHub
parent 7b5dad2321
commit c295de661c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -1622,12 +1622,12 @@ To get the root and extension of a path or file name (new in version 2.0)::
# with path == 'nginx.conf' the return would be ('nginx', '.conf') # with path == 'nginx.conf' the return would be ('nginx', '.conf')
{{ path | splitext }} {{ path | splitext }}
The ``splitext`` filter returns a string. The individual components can be accessed by using the ``first`` and ``last`` filters:: The ``splitext`` filter always returns a pair of strings. The individual components can be accessed by using the ``first`` and ``last`` filters::
# with path == 'nginx.conf' the return would be 'nginx' # with path == 'nginx.conf' the return would be 'nginx'
{{ path | splitext | first }} {{ path | splitext | first }}
# with path == 'nginx.conf' the return would be 'conf' # with path == 'nginx.conf' the return would be '.conf'
{{ path | splitext | last }} {{ path | splitext | last }}
To join one or more path components:: To join one or more path components::

Loading…
Cancel
Save