mirror of
https://github.com/gohugoio/hugo.git
synced 2025-08-26 22:04:32 +02:00
tpl/collections: Add Merge function
Merges two maps recursively and returns a new one. Merge is case-insensitive. Fixes #5992
This commit is contained in:
@@ -183,6 +183,16 @@ func init() {
|
||||
},
|
||||
)
|
||||
|
||||
ns.AddMethodMapping(ctx.Merge,
|
||||
[]string{"merge"},
|
||||
[][2]string{
|
||||
{`{{ dict "title" "Hugo Rocks!" | collections.Merge (dict "title" "Default Title" "description" "Yes, Hugo Rocks!") | sort }}`,
|
||||
`[Yes, Hugo Rocks! Hugo Rocks!]`},
|
||||
{`{{ merge (dict "title" "Default Title" "description" "Yes, Hugo Rocks!") (dict "title" "Hugo Rocks!") | sort }}`,
|
||||
`[Yes, Hugo Rocks! Hugo Rocks!]`},
|
||||
},
|
||||
)
|
||||
|
||||
return ns
|
||||
|
||||
}
|
||||
|
Reference in New Issue
Block a user