mirror of
https://github.com/gohugoio/hugo.git
synced 2025-08-21 21:35:28 +02:00
Merge commit '35dec7c96f7ee3eb17dd444f7067f0c776fb56ae'
This commit is contained in:
@@ -1,31 +1,27 @@
|
||||
---
|
||||
title: chomp
|
||||
linkTitle: chomp
|
||||
description: Removes any trailing newline characters.
|
||||
categories: [functions]
|
||||
title: strings.Chomp
|
||||
description: Returns the given string, removing all trailing newline characters and carriage returns.
|
||||
categories: []
|
||||
keywords: []
|
||||
menu:
|
||||
docs:
|
||||
parent: functions
|
||||
function:
|
||||
action:
|
||||
aliases: [chomp]
|
||||
related:
|
||||
- functions/strings/Trim
|
||||
- functions/strings/TrimLeft
|
||||
- functions/strings/TrimPrefix
|
||||
- functions/strings/TrimRight
|
||||
- functions/strings/TrimSuffix
|
||||
returnType: any
|
||||
signatures: [strings.Chomp STRING]
|
||||
relatedFunctions:
|
||||
- strings.Chomp
|
||||
- strings.Trim
|
||||
- strings.TrimLeft
|
||||
- strings.TrimPrefix
|
||||
- strings.TrimRight
|
||||
- strings.TrimSuffix
|
||||
aliases: [/functions/chomp]
|
||||
---
|
||||
|
||||
If the argument is of type template.HTML, returns template.HTML, else returns a string.
|
||||
|
||||
|
||||
Useful in a pipeline to remove newlines added by other processing (e.g., [`markdownify`](/functions/transform/markdownify)).
|
||||
If the argument is of type `template.HTML`, returns `template.HTML`, else returns a `string`.
|
||||
|
||||
```go-html-template
|
||||
{{ chomp "<p>Blockhead</p>\n" }} → "<p>Blockhead</p>"
|
||||
{{ chomp | "foo\n" }} → foo
|
||||
{{ chomp | "foo\n\n" }} → foo
|
||||
|
||||
{{ chomp | "foo\r\n" }} → foo
|
||||
{{ chomp | "foo\r\n\r\n" }} → foo
|
||||
```
|
||||
|
Reference in New Issue
Block a user