From fde6cbeb6868f38d1bb02454a5f6413c91935f5b Mon Sep 17 00:00:00 2001 From: Dave Henderson Date: Thu, 29 Dec 2022 09:45:38 -0500 Subject: Add strings.SkipLines function Signed-off-by: Dave Henderson --- docs/content/functions/strings.md | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) (limited to 'docs/content/functions/strings.md') diff --git a/docs/content/functions/strings.md b/docs/content/functions/strings.md index 57d3965f..37859d5a 100644 --- a/docs/content/functions/strings.md +++ b/docs/content/functions/strings.md @@ -207,6 +207,42 @@ $ gomplate -i '{{ (coll.Slice "foo" "bar" "baz") | strings.Sort }}' [bar baz foo] ``` +## `strings.SkipLines` + +Skips the given number of lines (each ending in a `\n`), returning the +remainder. + +If `skip` is greater than the number of lines in `in`, an empty string is +returned. + +### Usage + +```go +strings.SkipLines skip in +``` +```go +in | strings.SkipLines skip +``` + +### Arguments + +| name | description | +|------|-------------| +| `skip` | _(required)_ the number of lines to skip - must be a positive number | +| `in` | _(required)_ the input string | + +### Examples + +```console +$ gomplate -i '{{ "foo\nbar\nbaz" | strings.SkipLines 2 }}' +baz +``` +```console +$ gomplate -i '{{ strings.SkipLines 1 "foo\nbar\nbaz" }}' +bar +baz +``` + ## `strings.Split` _Not to be confused with [`split`](#split), which is deprecated._ -- cgit v1.2.3