diff options
Diffstat (limited to 'docs')
| -rw-r--r-- | docs/content/functions/env.md | 26 | ||||
| -rw-r--r-- | docs/content/functions/general.md | 18 | ||||
| -rw-r--r-- | docs/content/syntax.md | 2 |
3 files changed, 27 insertions, 19 deletions
diff --git a/docs/content/functions/env.md b/docs/content/functions/env.md new file mode 100644 index 00000000..ebbf8427 --- /dev/null +++ b/docs/content/functions/env.md @@ -0,0 +1,26 @@ +--- +title: env functions +menu: + main: + parent: functions +--- + +## `env.Getenv` + +**Alias:** `getenv` + +Exposes the [os.Getenv](https://golang.org/pkg/os/#Getenv) function. + +This is a more forgiving alternative to using `.Env`, since missing keys will +return an empty string. + +An optional default value can be given as well. + +#### Example + +```console +$ gomplate -i 'Hello, {{env.Getenv "USER"}}' +Hello, hairyhenderson +$ gomplate -i 'Hey, {{getenv "FIRSTNAME" "you"}}!' +Hey, you! +```
\ No newline at end of file diff --git a/docs/content/functions/general.md b/docs/content/functions/general.md index 32aa6820..ab362573 100644 --- a/docs/content/functions/general.md +++ b/docs/content/functions/general.md @@ -5,24 +5,6 @@ menu: parent: functions --- -## `getenv` - -Exposes the [os.Getenv](https://golang.org/pkg/os/#Getenv) function. - -This is a more forgiving alternative to using `.Env`, since missing keys will -return an empty string. - -An optional default value can be given as well. - -#### Example - -```console -$ gomplate -i 'Hello, {{getenv "USER"}}' -Hello, hairyhenderson -$ gomplate -i 'Hey, {{getenv "FIRSTNAME" "you"}}!' -Hey, you! -``` - ## `bool` Converts a true-ish string to a boolean. Can be used to simplify conditional statements based on environment variables or other text input. diff --git a/docs/content/syntax.md b/docs/content/syntax.md index e68af3b5..cbd63f4c 100644 --- a/docs/content/syntax.md +++ b/docs/content/syntax.md @@ -13,7 +13,7 @@ will fail and `gomplate` will exit with an error condition. Sometimes, this behaviour is desired; if the output is unusable without certain strings, this is a sure way to know that variables are missing! -If you want different behaviour, try [`getenv`](../functions/#getenv). +If you want different behaviour, try [`getenv`](../functions/env/#env-getenv). ## Built-in functions |
