mirror of
				https://github.com/gohugoio/hugo.git
				synced 2024-05-11 05:54:58 +00:00 
			
		
		
		
	Merge commit '83bef6955e014d40c0f00db9cebe09113154e999'
This commit is contained in:
		
							
								
								
									
										42
									
								
								docs/content/en/functions/trim.md
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										42
									
								
								docs/content/en/functions/trim.md
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,42 @@ | ||||
| --- | ||||
| title: trim | ||||
| # linktitle: | ||||
| description: Returns a slice of a passed string with all leading and trailing characters from cutset removed. | ||||
| godocref: | ||||
| date: 2017-02-01 | ||||
| publishdate: 2017-02-01 | ||||
| lastmod: 2017-02-01 | ||||
| categories: [functions] | ||||
| menu: | ||||
|   docs: | ||||
|     parent: "functions" | ||||
| keywords: [strings] | ||||
| signature: ["trim INPUT CUTSET"] | ||||
| workson: [] | ||||
| hugoversion: | ||||
| relatedfuncs: [] | ||||
| deprecated: false | ||||
| --- | ||||
|  | ||||
| ``` | ||||
| {{ trim "++Batman--" "+-" }} → "Batman" | ||||
| ``` | ||||
|  | ||||
| `trim` *requires* the second argument, which tells the function specifically what to remove from the first argument. There is no default value for the second argument, so **the following usage will not work**: | ||||
|  | ||||
| ``` | ||||
| {{ trim .Inner}} | ||||
| ``` | ||||
|  | ||||
| Instead, the following example tells `trim` to remove extra new lines from the content contained in the [shortcode `.Inner` variable][shortcodevars]: | ||||
|  | ||||
| ``` | ||||
| {{ trim .Inner "\n" }} | ||||
| ``` | ||||
|  | ||||
| {{% note %}} | ||||
| Go templates also provide a simple [method for trimming whitespace](/templates/introduction/#whitespace) from either side of a Go tag by including a hyphen (`-`). | ||||
| {{% /note %}} | ||||
|  | ||||
|  | ||||
| [shortcodevars]: /variables/shortcodes/ | ||||
		Reference in New Issue
	
	Block a user