mirror of
https://github.com/gohugoio/hugo.git
synced 2025-08-21 21:35:28 +02:00
Merge commit 'f96384a3b596f9bc0a3a035970b09b2c601f0ccb'
This commit is contained in:
@@ -1,32 +1,24 @@
|
||||
---
|
||||
title: in
|
||||
linktitle:
|
||||
description: Checks if an element is in an array or slice--or a substring in a string---and returns a boolean.
|
||||
date: 2017-02-01
|
||||
publishdate: 2017-02-01
|
||||
lastmod: 2017-02-01
|
||||
categories: [functions]
|
||||
menu:
|
||||
docs:
|
||||
parent: "functions"
|
||||
parent: functions
|
||||
keywords: [strings]
|
||||
signature: ["in SET ITEM"]
|
||||
workson: []
|
||||
hugoversion:
|
||||
relatedfuncs: []
|
||||
deprecated: false
|
||||
aliases: []
|
||||
---
|
||||
|
||||
The elements supported are strings, integers and floats, although only float64 will match as expected.
|
||||
|
||||
In addition, `in` can also check if a substring exists in a string.
|
||||
|
||||
```
|
||||
```go-html-template
|
||||
{{ if in .Params.tags "Git" }}Follow me on GitHub!{{ end }}
|
||||
```
|
||||
|
||||
|
||||
```
|
||||
```go-html-template
|
||||
{{ if in "this string contains a substring" "substring" }}Substring found!{{ end }}
|
||||
```
|
||||
|
Reference in New Issue
Block a user