Skip to content

Commit 1998ecc

Browse files
Ivan De Marinodetro
authored andcommitted
Document template data fields and functions
1 parent 35b2c89 commit 1998ecc

1 file changed

Lines changed: 41 additions & 16 deletions

File tree

README.md

Lines changed: 41 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -128,22 +128,47 @@ For examples:
128128

129129
### Templates
130130

131-
The templates are implemented with Go [`text/template`](https://golang.org/pkg/text/template/) using the following objects and functions:
132-
133-
#### Template Objects
134-
135-
TBD
136-
137-
#### Template Functions
138-
139-
| Function | Description |
140-
|-----------------|--------------------------------------------------------------------------------------------------------------------|
141-
| `codefile` | Create a Markdown code block and populate it with the contents of a file. Path is relative to the repository root. |
142-
| `tffile` | A special case of the `codefile` function. In addition this will elide lines with an `OMIT` comment. |
143-
| `trimspace` | `strings.TrimSpace` |
144-
| `plainmarkdown` | Render Markdown content as plaintext |
145-
| `split` | Split string into sub-strings, eg. `split .Name "_"` |
146-
131+
The templates are implemented with Go [`text/template`](https://golang.org/pkg/text/template/)
132+
using the following data fields and functions:
133+
134+
#### Data fields
135+
136+
##### Provider
137+
138+
| Field | Type | Description |
139+
|------------------------:|:------:|-------------------------------------------------------------------------------------------|
140+
| `.Description` | string | Provider description |
141+
| `.HasExample` | bool | Is there an example file? |
142+
| `.ExampleFile` | string | Path to the file with the terraform configuration example |
143+
| `.ProviderName` | string | Canonical provider name (ex. `terraform-provider-random`) |
144+
| `.ProviderShortName` | string | Short version of the provider name (ex. `random`) |
145+
| `.RenderedProviderName` | string | Value provided via argument `--rendered-provider-name`, otherwise same as `.ProviderName` |
146+
147+
##### Resources / Data Source
148+
149+
| Field | Type | Description |
150+
|------------------------:|:------:|-------------------------------------------------------------------------------------------|
151+
| `.Name` | string | Name of the resource/data-source (ex. `tls_certificate`) |
152+
| `.Type` | string | Either `Resource` or `Data Source` |
153+
| `.Description` | string | Resource / Data Source description |
154+
| `.HasExample` | bool | Is there an example file? |
155+
| `.ExampleFile` | string | Path to the file with the terraform configuration example |
156+
| `.HasImport` | bool | Is there an import file? |
157+
| `.ImportFile` | string | Path to the file with the command for importing the resource |
158+
| `.ProviderName` | string | Canonical provider name (ex. `terraform-provider-random`) |
159+
| `.ProviderShortName` | string | Short version of the provider name (ex. `random`) |
160+
| `.RenderedProviderName` | string | Value provided via argument `--rendered-provider-name`, otherwise same as `.ProviderName` |
161+
162+
#### Functions
163+
164+
| Function | Description |
165+
|-----------------|---------------------------------------------------------------------------------------------------|
166+
| `codefile` | Create a Markdown code block with the content of a file. Path is relative to the repository root. |
167+
| `plainmarkdown` | Render Markdown content as plaintext. |
168+
| `prefixlines` | Add a prefix to all (newline-separated) lines in a string. |
169+
| `split` | Split string into sub-strings, by a given separator (ex. `split .Name "_"`). |
170+
| `tffile` | A special case of the `codefile` function, designed for Terraform files (i.e. `.tf`). |
171+
| `trimspace` | Equivalent to [`strings.TrimSpace`](https://pkg.go.dev/strings#TrimSpace). |
147172

148173
## Disclaimer
149174

0 commit comments

Comments
 (0)