Skip to content

Commit c15ce3b

Browse files
authored
Improve Go text/template helpers docs (#70)
1 parent 8961f05 commit c15ce3b

File tree

2 files changed

+23
-2
lines changed

2 files changed

+23
-2
lines changed

docs/go-text-template-helpers.md

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
This file documents helper functions available when using the Go `text/template` template engine.
2+
3+
Within this template is possible to use **all** helpers from [`mastermings/sprig`](https://masterminds.github.io/sprig/).
4+
5+
<!-- helpers MUST be alphabetically sorted -->
6+
7+
# `awsAZFromRegion`
8+
9+
This helper accepts a string representing an AWS region (es. `us-east-1`) and returns a valid Availability Zone from that AWS region.
10+
11+
_NOTE_: Not all regions are supported at the moment (but can be added at need). For supported regions look [here](https://github.com/elastic/elastic-integration-corpus-generator-tool/blob/2c64e07461467aef4faacd5eb41efc3b0399c270/pkg/genlib/generator_with_text_template.go#L28-L30)
12+
13+
**Example**:
14+
15+
```text
16+
{{ awsAZFromRegion "us-east-1" }}
17+
```
18+
```text
19+
us-east-1a
20+
```

docs/writing-templates.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,5 +76,6 @@ This is equivalent to the following when using the `placeholder` template type:
7676
{{ .Field1 }}
7777
```
7878

79-
#### sprig functions
80-
The template loads the functions provided by sprig (https://masterminds.github.io/sprig/) with the exclusion of the functions are not guaranteed to evaluate to the same result for given input (https://github.com/Masterminds/sprig/blob/581758eb7d96ae4d113649668fa96acc74d46e7f/functions.go#L68-L95)
79+
#### Helpers
80+
81+
This template type supports other [helper functions](./go-text-template-helpers.md).

0 commit comments

Comments
 (0)