summaryrefslogtreecommitdiff
path: root/docs
diff options
context:
space:
mode:
authorDave Henderson <dhenderson@gmail.com>2018-11-17 13:01:20 -0500
committerDave Henderson <dhenderson@gmail.com>2018-11-17 13:01:20 -0500
commita95a25dac45df2fd04fba321eb66dbb868c1283a (patch)
treee6e8b0d9d451b2ce5e64dfec6e08f749722940d1 /docs
parent0cf7734ef776cc7701dfbb08b080cecf5066f0eb (diff)
Adding quote and squote functions
Signed-off-by: Dave Henderson <dhenderson@gmail.com>
Diffstat (limited to 'docs')
-rw-r--r--docs/content/functions/strings.md70
1 files changed, 70 insertions, 0 deletions
diff --git a/docs/content/functions/strings.md b/docs/content/functions/strings.md
index 1f1dae42..460212ad 100644
--- a/docs/content/functions/strings.md
+++ b/docs/content/functions/strings.md
@@ -224,6 +224,44 @@ foo
bar:baz
```
+## `strings.Quote`
+
+**Alias:** `quote`
+
+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" }}
+```
+
+### Usage
+```go
+strings.Quote in
+```
+
+```go
+in | strings.Quote
+```
+
+### Arguments
+
+| name | description |
+|------|-------------|
+| `in` | _(required)_ The input to quote |
+
+### Examples
+
+```console
+$ gomplate -i '{{ "in" | quote }}'
+"in"
+$ gomplate -i '{{ strings.Quote 500 }}'
+"500"
+```
+
## `strings.Repeat`
Returns a new string consisting of `count` copies of the input string.
@@ -291,6 +329,38 @@ $ echo 'Rock & Roll @ Cafe Wha?' | gomplate -d in=stdin: -i '{{ strings.Slug (in
rock-and-roll-at-cafe-wha
```
+## `strings.Squote`
+
+**Alias:** `squote`
+
+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: `''`).
+
+### Usage
+```go
+strings.Squote in
+```
+
+```go
+in | strings.Squote
+```
+
+### Arguments
+
+| name | description |
+|------|-------------|
+| `in` | _(required)_ The input to quote |
+
+### Examples
+
+```console
+$ gomplate -i '{{ "in" | squote }}'
+'in'
+$ gomplate -i "{{ strings.Squote \"it's a banana\" }}"
+'it''s a banana'
+```
+
## `strings.Title`
**Alias:** `title`