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

Invalid documentation for coll.GoSlice #1517

Closed
vitoyucepi opened this issue Oct 6, 2022 · 3 comments · Fixed by #1518
Closed

Invalid documentation for coll.GoSlice #1517

vitoyucepi opened this issue Oct 6, 2022 · 3 comments · Fixed by #1518
Assignees

Comments

@vitoyucepi
Copy link

Summary

In #1464 coll.GoSlice was introduced, but example for that function uses coll.Slice instead.

```go
coll.GoSlice item [indexes...]
```
### Arguments
| name | description |
|------|-------------|
| `item` | _(required)_ the string, slice, or array to slice |
| `indexes...` | _(optional)_ the indexes to slice the item by (0 to 3 arguments) |
### Examples
```console
$ gomplate -i '{{ $l := coll.Slice "foo" "bar" "baz" }}{{ if has $l "bar" }}a{{else}}no{{end}} bar'
```

@hairyhenderson
Copy link
Owner

Thanks for filing this @vitoyucepi!

This is indeed a bug. I'll fix the docs soon.

Note that this is a new function that hasn't made its way into a release yet, so you'll have to compile gomplate yourself to be able to use it.

@vitoyucepi
Copy link
Author

I have no plans to use this feature yet.
I came here because the slice function was deprecated in #1464. I use it in {{ tmpl.Exec "sometemplate" (slice "val1" "val2") }}.
Though I think it'll be acceptable to use coll.Slice instead.

@hairyhenderson
Copy link
Owner

Though I think it'll be acceptable to use coll.Slice instead.

Yup, exactly. coll.Slice is what you want where you used to use slice

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

Successfully merging a pull request may close this issue.

2 participants