Merge commit 'f96384a3b596f9bc0a3a035970b09b2c601f0ccb'

This commit is contained in:
Bjørn Erik Pedersen
2023-05-22 16:47:07 +02:00
341 changed files with 3107 additions and 4238 deletions

View File

@@ -1,21 +1,48 @@
---
title: string
# linktitle: string
description: Creates a string from the argument passed to the function
date: 2017-02-01
publishdate: 2017-02-01
lastmod: 2017-02-01
description: Cast a value to a string.
categories: [functions]
menu:
docs:
parent: "functions"
keywords: [strings]
parent: functions
keywords: [cast,strings]
signature: ["string INPUT"]
workson: []
hugoversion:
relatedfuncs: []
deprecated: false
aliases: []
---
* `{{string "BatMan"}}` → "BatMan"
With a decimal (base 10) input:
```go-html-template
{{ string 11 }} → 11 (string)
{{ string "11" }} → 11 (string)
{{ string 11.1 }} → 11.1 (string)
{{ string "11.1" }} → 11.1 (string)
{{ string 11.9 }} → 11.9 (string)
{{ string "11.9" }} → 11.9 (string)
```
With a binary (base 2) input:
```go-html-template
{{ string 0b11 }} → 3 (string)
{{ string "0b11" }} → 0b11 (string)
```
With an octal (base 8) input (use either notation):
```go-html-template
{{ string 011 }} → 9 (string)
{{ string "011" }} → 011 (string)
{{ string 0o11 }} → 9 (string)
{{ string "0o11" }} → 0o11 (string)
```
With a hexadecimal (base 16) input:
```go-html-template
{{ string 0x11 }} → 17 (string)
{{ string "0x11" }} → 0x11 (string)
```