Files
hugo/docs/content/en/functions/collections/Apply.md
T
Bjørn Erik Pedersen 30a20122b7 Merge commit '8f3c066d23f431fb2c53d97ea489e4c28b42bd82'
# Conflicts:
#	docs/data/docs.yaml
2026-02-14 12:14:33 +01:00

866 B

title, description, categories, keywords, params, aliases
title description categories keywords params aliases
collections.Apply Returns a slice by transforming each element of the given slice using a specific function and parameters.
functions_and_methods
aliases returnType signatures
apply
[]any
collections.Apply SLICE FUNCTION PARAM...
/functions/apply

The apply function takes three or more arguments, depending on the function being applied to the slice elements.

The first argument is the slice itself, the second argument is the function name, and the remaining arguments are passed to the function, with the string "." representing the slice element.

{{ $s := slice "hello" "world" }}

{{ $s = apply $s "strings.FirstUpper" "." }}
{{ $s }} → [Hello World]

{{ $s = apply $s "strings.Replace" "." "l" "_" }}
{{ $s }} →  [He__o Wor_d]