-
-
Notifications
You must be signed in to change notification settings - Fork 7.5k
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
Add after
template function to complement first
#1200
Conversation
Where `first` will return the first N items of a rangeable list, `after` will return all items after the Nth item. This allows the user to do something with the first N items and something different with the remaining items after N.
@@ -177,7 +177,7 @@ func Substr(a interface{}, nums ...interface{}) (string, error) { | |||
} | |||
|
|||
var start, length int | |||
toInt := func (v interface{}, message string) (int, error) { | |||
toInt := func(v interface{}, message string) (int, error) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Change made by gofmt
.
@spf13 |
no. It's all good. Go fmt is a good thing. |
I feel like we need a last as well following this change. |
@spf13 seems like a good idea, while I'm at it. Give me few moments... 🕦 |
`last` allows the user to select the last X items of and array.
@spf13 pending tests, here's your |
Merged in cc9536e Very useful. And with docs AND tests. Me like. |
❤️ |
This pull request has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
The
first
template function allows the user to select the first X items of an array. I have a use case where I want those X first items, but I also want the rest of the items after X for separate processing.after
adds this functionality.There is one open question and that's the one of naming things 😈
Is
after
properly named? I chose it overremaining
, as the supplied limit would not make sense. Are there any other candidates that need to be considered? /cc @spf13 what's your opinion on this?