From bdf3a1eb92020a0d1ce202df14b49f2f13445476 Mon Sep 17 00:00:00 2001 From: Javier Solana Date: Sat, 6 Jul 2024 15:32:01 +0200 Subject: feat(strings): New functions TrimRight and TrimLeft (#2148) Signed-off-by: Javier Solana javier.solana@cabify.com Signed-off-by: Javier Solana javier.solana@cabify.com Co-authored-by: Javier Solana --- docs/content/functions/strings.md | 58 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 58 insertions(+) (limited to 'docs') diff --git a/docs/content/functions/strings.md b/docs/content/functions/strings.md index fe37830f..9ec1589a 100644 --- a/docs/content/functions/strings.md +++ b/docs/content/functions/strings.md @@ -669,6 +669,35 @@ $ gomplate -i '{{ "_-foo-_" | strings.Trim "_-" }}' foo ``` +## `strings.TrimLeft`_(unreleased)_ +**Unreleased:** _This function is in development, and not yet available in released builds of gomplate._ + +Trims a string by removing the given characters from the beginning of the string. +This wraps Go's [`strings.TrimLeft`](https://pkg.go.dev/strings#TrimLeft). + +### Usage + +``` +strings.TrimLeft cutset input +``` +``` +input | strings.TrimLeft cutset +``` + +### Arguments + +| name | description | +|------|-------------| +| `cutset` | _(required)_ the set of characters to cut | +| `input` | _(required)_ the input | + +### Examples + +```console +$ gomplate -i '{{ " - hello, world!" | strings.TrimLeft " " }}' +- hello, world! +``` + ## `strings.TrimPrefix` Returns a string without the provided leading prefix string, if the prefix is present. @@ -699,6 +728,35 @@ $ gomplate -i '{{ "hello, world" | strings.TrimPrefix "hello, " }}' world ``` +## `strings.TrimRight`_(unreleased)_ +**Unreleased:** _This function is in development, and not yet available in released builds of gomplate._ + +Trims a string by removing the given characters from the end of the string. +This wraps Go's [`strings.TrimRight`](https://pkg.go.dev/strings#TrimRight). + +### Usage + +``` +strings.TrimRight cutset input +``` +``` +input | strings.TrimRight cutset +``` + +### Arguments + +| name | description | +|------|-------------| +| `cutset` | _(required)_ the set of characters to cut | +| `input` | _(required)_ the input | + +### Examples + +```console +$ gomplate -i '{{ "hello, world! " | strings.TrimRight " " }}' +hello, world! +``` + ## `strings.TrimSpace` **Alias:** `trimSpace` -- cgit v1.2.3