diff options
| author | Dave Henderson <dhenderson@gmail.com> | 2019-02-17 14:54:28 -0500 |
|---|---|---|
| committer | Dave Henderson <dhenderson@gmail.com> | 2019-02-17 16:20:41 -0500 |
| commit | 2065fe0d4818515300dadd63bf70ee7629f8e91b (patch) | |
| tree | 09d55085da86d2e535662c3746b55c31985a4f2f /docs-src | |
| parent | a9b3f9390642d3f361f64528073e3199a116222a (diff) | |
New strings.WordWrap function
Signed-off-by: Dave Henderson <dhenderson@gmail.com>
Diffstat (limited to 'docs-src')
| -rw-r--r-- | docs-src/content/functions/strings.yml | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/docs-src/content/functions/strings.yml b/docs-src/content/functions/strings.yml index 773b7154..aba08319 100644 --- a/docs-src/content/functions/strings.yml +++ b/docs-src/content/functions/strings.yml @@ -112,3 +112,35 @@ funcs: - | $ gomplate -i '{{ "hello jello" | strings.KebabCase }}' hello-jello + - name: strings.WordWrap + description: | + Inserts new line breaks into the input string so it ends up with lines that are at most `width` characters wide. + + The line-breaking algorithm is _naïve_ and _greedy_: lines are only broken between words (i.e. on whitespace characters), and no effort is made to "smooth" the line endings. + + When words that are longer than the desired width are encountered (e.g. long URLs), they are not broken up. Correctness is valued above line length. + + The line-break sequence defaults to `\n` (i.e. the LF/Line Feed character), regardless of OS. + pipeline: true + arguments: + - name: width + required: false + description: The desired maximum line length (number of characters - defaults to `80`) + - name: lbseq + required: false + description: The line-break sequence to use (defaults to `\n`) + - name: in + required: true + description: The input + examples: + - | + $ gomplate -i '{{ "Hello, World!" | strings.WordWrap 7 }}' + Hello, + World! + - | + $ gomplate -i '{{ strings.WordWrap 20 "\\\n" "a string with a long url http://example.com/a/very/long/url which should not be broken" }}' + a string with a long + url + http://example.com/a/very/long/url + which should not be + broken |
