diff options
| author | Dave Henderson <dhenderson@gmail.com> | 2018-11-17 13:01:20 -0500 |
|---|---|---|
| committer | Dave Henderson <dhenderson@gmail.com> | 2018-11-17 13:01:20 -0500 |
| commit | a95a25dac45df2fd04fba321eb66dbb868c1283a (patch) | |
| tree | e6e8b0d9d451b2ce5e64dfec6e08f749722940d1 /docs-src | |
| parent | 0cf7734ef776cc7701dfbb08b080cecf5066f0eb (diff) | |
Adding quote and squote functions
Signed-off-by: Dave Henderson <dhenderson@gmail.com>
Diffstat (limited to 'docs-src')
| -rw-r--r-- | docs-src/content/functions/strings.yml | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/docs-src/content/functions/strings.yml b/docs-src/content/functions/strings.yml index 6e3807c3..172184db 100644 --- a/docs-src/content/functions/strings.yml +++ b/docs-src/content/functions/strings.yml @@ -1,6 +1,29 @@ ns: strings preamble: '' funcs: + - name: strings.Quote + alias: quote + description: | + Surrounds an input string with double-quote characters (`"`). If the input is not a string, converts first. + + `"` characters in the input are first escaped with a `\` character. + + This is a convenience function which is equivalent to: + + ``` + {{ print "%q" "input string" }} + ``` + pipeline: true + arguments: + - name: in + required: true + description: The input to quote + examples: + - | + $ gomplate -i '{{ "in" | quote }}' + "in" + $ gomplate -i '{{ strings.Quote 500 }}' + "500" - name: strings.Sort alias: sort description: | @@ -14,3 +37,20 @@ funcs: - | $ gomplate -i '{{ (slice "foo" "bar" "baz") | sort }}' [bar baz foo] + - name: strings.Squote + alias: squote + description: | + Surrounds an input string with a single-quote (apostrophe) character (`'`). If the input is not a string, converts first. + + `'` characters in the input are first escaped in the YAML-style (by repetition: `''`). + pipeline: true + arguments: + - name: in + required: true + description: The input to quote + examples: + - | + $ gomplate -i '{{ "in" | squote }}' + 'in' + $ gomplate -i "{{ strings.Squote \"it's a banana\" }}" + 'it''s a banana' |
