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-src/content/functions/strings.yml | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) (limited to 'docs-src') diff --git a/docs-src/content/functions/strings.yml b/docs-src/content/functions/strings.yml index 07378fb0..8c10a8f5 100644 --- a/docs-src/content/functions/strings.yml +++ b/docs-src/content/functions/strings.yml @@ -421,6 +421,23 @@ funcs: - | $ gomplate -i '{{ "_-foo-_" | strings.Trim "_-" }}' foo + - name: strings.TrimLeft + # released: v4.1.0 + description: | + 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). + pipeline: true + arguments: + - name: cutset + required: true + description: the set of characters to cut + - name: input + required: true + description: the input + examples: + - | + $ gomplate -i '{{ " - hello, world!" | strings.TrimLeft " " }}' + - hello, world! - name: strings.TrimPrefix released: v2.5.0 description: | @@ -439,6 +456,23 @@ funcs: - | $ gomplate -i '{{ "hello, world" | strings.TrimPrefix "hello, " }}' world + - name: strings.TrimRight + # released: v4.1.0 + description: | + 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). + pipeline: true + arguments: + - name: cutset + required: true + description: the set of characters to cut + - name: input + required: true + description: the input + examples: + - | + $ gomplate -i '{{ "hello, world! " | strings.TrimRight " " }}' + hello, world! - name: strings.TrimSpace alias: trimSpace released: v1.9.0 -- cgit v1.2.3