Michael Halim
Michael Halim

Reputation: 726

Is it possible to access value in a list in Revel Template

{{ range .foo }}
                
{{end}}

.

{{range $index, $element := .foo }}

{{end}}

I'm aware that you can use this like for loop, but is there any other way to access a value in array directly like {{ foo[2] }} in Revel Template? I've read this Revel documentation but doesn't seem to find any.

Upvotes: 0

Views: 67

Answers (1)

Burak Serdar
Burak Serdar

Reputation: 51662

It is not Revel specific, indexing is included in the standard library templates:

{{index .foo 2}}

Upvotes: 2

Related Questions