ext_trim

Returns the file path without its trailing extension.

Only the final extension is removed, so a path like "archive.tar.gz" keeps its "tar" segment and loses just ".gz". Directory segments are preserved untouched. A path with no extension, or one whose last element is a directory (trailing slash), comes back unchanged. A dotfile with nothing before the dot, such as ".gitignore", is treated by the standard library as being all extension, so trimming it yields an empty string.

InputArgumentsReturnsstringno argumentsstring
Source
BasicSource

Returns the path without its trailing extension, removing only the final segment and preserving the directory portion.

Given

{"path": "docs/report.pdf"}

Template

{{ path | ext_trim }}

Result

docs/report
Hidden directorySource

Trims the extension from a file that lives inside a leading-dot directory, keeping the hidden directory intact.

Given

{"path": ".config/settings.json"}

Template

{{ path | ext_trim }}

Result

.config/settings
Multi extensionSource

Removes only the final extension, so a double-suffixed archive keeps its inner segment.

Given

{"path": "backup/archive.tar.gz"}

Template

{{ path | ext_trim }}

Result

backup/archive.tar
No extensionSource

Leaves a path that has no extension exactly as it was.

Given

{"path": "bin/tool"}

Template

{{ path | ext_trim }}

Result

bin/tool