Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -408,6 +408,8 @@ using the following data fields and functions:
| Function | Example | Description |
|-----------------|--------------------------------------------------|---------------------------------------------------------------------------------------------------|
| `codefile` | `{{codefile "shell" "path/to/file.sh"}}` | Create a Markdown code block with the content of a file. Path is relative to the repository root. |
| `hasPrefix` | `{{if hasPrefix "FOO BAR" "FOO"}}` | Equivalent to [`strings.HasPrefix`](https://pkg.go.dev/strings#HasPrefix). |
| `hasSuffix` | `{{if hasSuffix "FOO BAR" "BAR"}}` | Equivalent to [`strings.HasSuffix`](https://pkg.go.dev/strings#HasSuffix). |
| `lower` | `{{"EXAMPLE STRING" \| lower}}` | Equivalent to [`strings.ToLower`](https://pkg.go.dev/strings#ToLower). |
| `plainmarkdown` | `{{"*example markdown*" \| plainmarkdown }}` | Render Markdown content as plaintext. |
| `prefixlines` | `{{"example string" \| prefixlines "prefix: "}}` | Add a prefix to all (newline-separated) lines in a string. |
Expand Down Expand Up @@ -489,4 +491,4 @@ cmp stdout expected-output.txt # compares stdout from binary with the golden fi
cmp docs/index.md expected-index.md # compares the generated docs with the golden file in the text archive below
cmp docs/data-sources/example.md expected-datasource.md # compares the generated docs with the golden file in the text archive below
cmp docs/resources/example.md expected-resource.md # compares the generated docs with the golden file in the text archive below
```
```
2 changes: 2 additions & 0 deletions internal/provider/template.go
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,8 @@ func newTemplate(providerDir, name, text string) (*template.Template, error) {

tmpl.Funcs(map[string]interface{}{
"codefile": codeFile(providerDir),
"hasPrefix": strings.HasPrefix,
"hasSuffix": strings.HasSuffix,
"lower": strings.ToLower,
"plainmarkdown": mdplain.PlainMarkdown,
"prefixlines": tmplfuncs.PrefixLines,
Expand Down