Skip to content
Permalink
Branch: master
Find file Copy path
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
41 lines (33 sloc) 876 Bytes
title description date categories menu keywords signature workson hugoversion relatedfuncs aliases
merge
`merge` deep merges two maps and returns the resulting map.
2019-08-08
functions
docs
parent
functions
dictionary
$params := merge $default_params $user_params
0.56.0
dict
append
reflect.IsMap
reflect.IsSlice

An example merging two maps.

{{ $default_params := dict "color" "blue" "width" "50%" "height" "25%" }}
{{ $user_params := dict "color" "red" "extra" (dict "duration" 2) }}
{{ $params := merge $default_params $user_params }}

Resulting $params:

"color": "red"
"extra":
  "duration": 2
"height": "25%"
"icon": "mail"
"width": "50%"

{{% note %}} Regardless of depth, merging only applies to maps. For slices, use [append]({{< ref "functions/append" >}}) {{% /note %}}

You can’t perform that action at this time.