trim_suffix
Removes the given suffix once from the end of a string, returning it unchanged when it does not end with that suffix.
InputArgumentsReturns
Sourcestringstringstringstringno argumentsstring[]bytestring[]byte[]byteno arguments[]byteBasicSource
Removes the given suffix once from the end.
Given
{"file": "report.txt"}Template
{{ file | trim_suffix:'.txt' }}Result
reportAbsentSource
Leaves the value unchanged when it does not end with the given suffix.
Given
{"file": "report.md"}Template
{{ file | trim_suffix:'.txt' }}Result
report.mdChainedSource
Strips a leading and a trailing slash by piping trim_prefix into trim_suffix.
Given
{"path": "/users/"}Template
{{ path | trim_prefix:'/' | trim_suffix:'/' }}Result
usersBasicSource
Strips trailing whitespace when trim_suffix is called without an argument, leaving leading whitespace in place.
Given
{"input": "Welcome aboard. "}Template
{{ input | trim_suffix }}Result
Welcome aboard.