Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

index template function #87

Closed
endorama opened this issue Mar 21, 2018 · 2 comments
Closed

index template function #87

endorama opened this issue Mar 21, 2018 · 2 comments

Comments

@endorama
Copy link

Hello, I spent some time understanding how to extract the element at index n of an Array

Es:

arr := [1,2,3]
I want to get arr[1] => 2

I finally found the index function, but is not documented in the docs and I did't find it's declaration in the code.

The usage is

{{ index arr 2 }}

and I found references in:

Where does it come from? Should be documented in the list.md doc file?

I'm sorry if it's something obvious, I'm new to go and sprig. I can provide a PR to the documentation if you point me in the right direction.

Thank you!

@mattfarina
Copy link
Member

@endorama The index function isn't part of sprig. Rather, it's part of the go templating functions. The following link has more details - https://golang.org/pkg/text/template/#hdr-Functions. That's why we don't document it here.

If you have further questions please feel free to re-open the issue.

@endorama
Copy link
Author

endorama commented Apr 4, 2018

@mattfarina Thank you!! It's all clear now. And thanks for the link to the docs, I did find that page but obviously missed/misunderstood that part.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants