filename
Returns the base file name from a path, the final path element including its extension.
A trailing slash is ignored, so the last real segment is returned.
InputArgumentsReturns
Sourcestringno argumentsstringBasicSource
Returns the base file name, the final path element including its extension.
Given
{"path": "docs/reports/q1.pdf"}Template
{{ path | filename }}Result
q1.pdfBare nameSource
Leaves a bare file name unchanged when there is no directory to strip.
Given
{"path": "config.yaml"}Template
{{ path | filename }}Result
config.yamlTrailing slashSource
Ignores a trailing slash and returns the last real segment of the path.
Given
{"path": "docs/reports/"}Template
{{ path | filename }}Result
reportsUnicodeSource
Returns the final segment of a multi-byte path untouched.
Given
{"path": "файлы/отчёт.pdf"}Template
{{ path | filename }}Result
отчёт.pdf