strings.Chomp
Returns the given string, removing all trailing newline characters and carriage returns.
- Syntax
- strings.Chomp STRING
- Returns
- any
- Alias
- chomp
Usage
The strings.Chomp function returns the given string, removing all trailing newline characters and carriage returns. If STRING is of type template.HTML, the function returns template.HTML, otherwise it returns a string.
Examples
{{ strings.Chomp "foo\n" }} → foo
{{ strings.Chomp "foo\n\n" }} → foo
{{ strings.Chomp "foo\r\n" }} → foo
{{ strings.Chomp "foo\r\n\r\n" }} → fooLast updated:
November 8, 2026
:
content: Remove categories from front matter (1cc1dd83a)
Improve this page