Kevin Bryan
Kevin Bryan

Reputation: 1858

How to var[0].var1[0] in Hugo template?

I can only do (index .var 0).var1 but my var1 is also an array, how do I select it's index?

Upvotes: 0

Views: 313

Answers (1)

VonC
VonC

Reputation: 1324547

From the Hugo index function:

Returns the result of indexing its first argument by the following arguments.

Thus “index x 1 2 3” is, in Go syntax, x[1][2][3].
Each indexed item must be a map, slice, or array.

In your case, do check if this would be enough (change the second '0' by the index you want to access within var1.

index .var 0 0

Upvotes: 3

Related Questions