[solved] Can you range with multiple slices? [YES!]

I’m trying to figure out how to make a simple table that looks like this:

Place Name
1 Winner
2 Second
3 Bronze
3 Co-Bronze
5 That Guy

I’m having some trouble figuring out how to store the data in the TOML and getting the range function to iterate 2 different slices at the same time.

I tried storing it this way:

place = [1, 2, 3, 3, 5]
name = [“Winner”, “Second”, “Bronze”, “Co-Bronze”, “That Guy”]

but I couldn’t figure out a way to use range to access both slices at the same index in the template.

Am I thinking about this the wrong way?

1 Like

I solved it, I didn’t know about “index”

{{ range $i, $temp := .Params.name }}


{{ index $.Params.place $i }}
{{ . }}
{{ end }}

Not entirely sure if I need the $temp :=, but it works right now.

1 Like