I have a custom variable $pages
.
{{$pages}}
gives [Product - A Product - B]
I would like to replace the values in $pages
with the values from a dictionary, $dictionary
that I have created.
{{$dictionary := (dict "Product - A" "Australia" "Product - B" "Belgium" "Product - C" "Canada")}}
{{range $pages}}
{{$.Scratch.Add "products" .}}
{{range $k, $v := $dictionary}}
{{$.Scratch.Set "products" (replace ($.Scratch.Get "products") $k $v)}}
{{end}}
{{end}}
{{$.Scratch.Get "products"}}
gives AustraliaBelgium
, one value instead of two values.
I need the output to be [Australia Belgium]
, two separate values, so that I can format it correctly for my JSON file.