mirror of
https://github.com/gohugoio/hugo.git
synced 2025-05-03 01:19:38 +00:00
1 KiB
1 KiB
title | description | categories | menu | keywords | signature | relatedfuncs | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
append | `append` appends one or more values to a slice and returns the resulting slice. |
|
|
|
|
|
An example appending single values:
{{ $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:
{{ $s := slice "a" "b" "c" }}
{{ $s = $s | append (slice "d" "e") }}
If a slice contains other slices, further slices will be appended as values:
{{ $s := slice (slice "a" "b") (slice "c" "d") }}
{{ $s = $s | append (slice "e" "f") (slice "g" "h") }}
{{/* $s now contains a [][]string containing four slices: ["a" "b"], ["c" "d"], ["e" "f"], and ["g" "h"] */}}
The append
function works for all types, including Pages
.