Cleanup hasPrefix hasSuffix

This commit is contained in:
Joe Mooring 2023-04-01 11:00:05 -07:00 committed by Joe Mooring
parent 7bee3e4c14
commit 47535dc873
4 changed files with 22 additions and 31 deletions

View File

@ -1,13 +0,0 @@
---
title: hasprefix
description: Tests whether a string begins with prefix.
categories: [functions]
menu:
docs:
parent: functions
keywords: [strings]
signature: ["hasPrefix STRING PREFIX"]
relatedfuncs: [hasSuffix]
---
* `{{ hasPrefix "Hugo" "Hu" }}` → true

View File

@ -1,13 +0,0 @@
---
title: hasSuffix
description: Tests whether a string ends with suffix.
categories: [functions]
menu:
docs:
parent: functions
keywords: [strings]
signature: ["hasSuffix STRING SUFFIX"]
relatedfuncs: [hasPrefix]
---
* `{{ hasSuffix "Hugo" "go" }}` → true

View File

@ -0,0 +1,16 @@
---
title: strings.HasPrefix
description: Tests whether a string begins with prefix.
categories: [functions]
menu:
docs:
parent: functions
keywords: [strings]
signature: ["hasPrefix STRING PREFIX","strings.HasPrefix STRING PREFIX"]
relatedfuncs: [hasSuffix]
aliases: [/functions/hasprefix/]
---
```go-html-template
{{ hasPrefix "Hugo" "Hu" }} → true
```

View File

@ -1,15 +1,16 @@
---
title: strings.HasSuffix
description: Determine whether a given string ends with the provided trailing suffix string.
description: Tests whether a string ends with suffix.
categories: [functions]
menu:
docs:
parent: functions
keywords: [strings]
signature: ["strings.HasSuffix STRING SUFFIX"]
signature: ["hasSuffix STRING SUFFIX","strings.HasSuffix STRING SUFFIX"]
relatedfuncs: [hasPrefix]
aliases: [/functions/hassuffix/]
---
{{ $pdfPath := "/path/to/some.pdf" }}
{{ strings.HasSuffix $pdfPath "pdf" }} → true
{{ strings.HasSuffix $pdfPath "txt" }} → false
```go-html-template
{{ hasSuffix "Hugo" "go" }} → true
```