From 7a42d2746200e560fa42edfe3a4e031f21411e38 Mon Sep 17 00:00:00 2001 From: Fixmetal Date: Thu, 23 Jul 2020 22:07:55 +0200 Subject: [PATCH] Proper example for splitext filter in docs (#70494) * Update playbooks_filters.rst with a clear example of how to extract its 2 tokens. Co-authored-by: Sloane Hertel --- docs/docsite/rst/user_guide/playbooks_filters.rst | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/docs/docsite/rst/user_guide/playbooks_filters.rst b/docs/docsite/rst/user_guide/playbooks_filters.rst index cc39d3be8fa..5e8b4a67950 100644 --- a/docs/docsite/rst/user_guide/playbooks_filters.rst +++ b/docs/docsite/rst/user_guide/playbooks_filters.rst @@ -1519,6 +1519,14 @@ 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') {{ path | splitext }} +The ``splitext`` filter returns a string. The individual components can be accessed by using the ``first`` and ``last`` filters:: + + # with path == 'nginx.conf' the return would be 'nginx' + {{ path | splitext | first }} + + # with path == 'nginx.conf' the return would be 'conf' + {{ path | splitext | last }} + To join one or more path components:: {{ ('/etc', path, 'subdir', file) | path_join }}