HUGO
Menu
GitHub 90272 stars Mastodon

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" }} → foo