wrap
Nests the value inside a new single-entry map under the given key.
The result is a map value, not a JSON string, so it is meant to be piped into an encoder such as json or yaml, or returned as structured data. A non-string key becomes the empty-string key rather than an error.
InputArgumentsReturns
Sourceanyanymap[string]anyBasicSource
Nests the value inside a new single-entry map under the given key.
Given
{"value": "Ada"}Template
{{ value | wrap:'name' }}Result
{
"name": "Ada"
}NumberSource
Nests any value type, including a number, under the key.
Given
{"count": 3}Template
{{ count | wrap:'total' }}Result
{
"total": 3
}SliceSource
Nests a slice under the key, keeping it as structured data rather than a string.
Given
{"items": ["a", "b"]}Template
{{ items | wrap:'list' }}Result
{
"list": [
"a",
"b"
]
}