append

将以下英文翻译为中文:

append

https://gohugo.io/functions/append/

append appends one or more values to a slice and returns the resulting slice.

语法

COLLECTION | append VALUE [VALUE]...
COLLECTION | append COLLECTION

An example appending single values:

1
2
3
{{ $s := slice "a" "b" "c" }}
{{ $s = $s | append "d" "e" }}
{{/* $s now contains a []string with elements "a", "b", "c", "d", and "e" */}}

The same example appending a slice to a slice:

1
2
{{ $s := slice "a" "b" "c" }}
{{ $s = $s | append (slice "d" "e") }}

The append function works for all types, including Pages.

另请参阅