I tried:
{{ if in $current .Params.bom }}
where $current is part-2 and .Params.bom is defined in the front matter as:
$current
part-2
.Params.bom
bom: { 'part-1' : 17, 'part-2' : 24 }
but that does not seem to evaluate to true. Neither if in .Params.bom $current.
if in .Params.bom $current
Also tried .Params.bom.$current but that is a syntax errror.
.Params.bom.$current
What’s the right way of doing this?
{{ $current := "part-2" }} {{ with .Params.bom }} {{ if index . $current }} ... ... {{ end }} {{ end }}
The syntax of in is by the way: in SET ITEM, not in ITEM SET. So your initial attempt might have worked too with exchanged parameters. But @jmooring has a better solution, because it checks if both, the set and the item are existing first.
in
in SET ITEM
in ITEM SET
This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.