diff --git a/website/docs/configuration/functions/templatefile.html.md b/website/docs/configuration/functions/templatefile.html.md index 55756bed9..5dd832105 100644 --- a/website/docs/configuration/functions/templatefile.html.md +++ b/website/docs/configuration/functions/templatefile.html.md @@ -49,6 +49,8 @@ to render templates while respecting resource dependencies. ## Examples +### Lists + Given a template file `backends.tmpl` with the following content: ``` @@ -66,6 +68,34 @@ backend 10.0.0.2:8080 ``` +### Maps + +Given a template file `config.tmpl` with the following content: + +``` +%{ for config_key, config_value in config } +set ${config_key} = ${config_value} +%{ endfor ~} +``` + +The `templatefile` function renders the template: + +``` +> templatefile( + "${path.module}/backends.tmpl", + { + config = { + "x" = "y" + "foo" = "bar" + "key" = "value" + } + } + ) +set foo = bar +set key = value +set x = y +``` + ### Generating JSON or YAML from a template If the string you want to generate will be in JSON or YAML syntax, it's