Okay so I have data files with yaml like this:
colors:
- name: Purple
sizes:
- Small
- Medium
- Large
- X-Large
- 2X-Large
- 3X-Large
- 4X-Large
- name: Pink
sizes:
- Small
- Medium
- Large
- X-Large
- 2X-Large
- 3X-Large
- 4X-Large
- name: Blue
sizes:
- Small
- Medium
- Large
- X-Large
- 2X-Large
- 3X-Large
- 4X-Large
- 5X-Large
I basically want to compare the size arrays and return one list for the ones that match.
I can’t help but think that the best place to start is to check the length of the sizes
arrays, but {{ if eq $len $len }}
returns an error: error calling index: can't index item of type int
Likewise, I tried to match one array against another using some variation of:
{{ intersect (index .sizes 0) (index .sizes 1) }}
and got these errors:
error calling intersect: can't iterate over string
and can't evaluate field sizes in type interface {}
Any pointing in the right direction would be great!