Document use of grammars in template/expression context
- Dominant language
- HCL
- Stars
- 31
- Forks
- 12
- Avg merge
- 7m
- Merged PRs (30d)
- 1
Description
## History
The main context in which we expect HCL/Terraform grammars to be used is to highlight whole HCL "bodies". For example
```hcl
attr = "foobar"
block "label" {
another = 42
}
ref = data.aws_instance.foo.tags["noot"]
```
The "expression" on the RHS after the `=` is part of the existing grammars and we happen to treat standalone expressions, such as
```hcl
42
"foobar"
data.aws_instance.foo.tags["noot"]
```
The decision to treat standalone expressions as valid was mostly pragmatic, where it was easier to do it than not to, due to the way TextMate grammars and nesting inside works.
To date however, this was a rather "hidden feature".
## Potential
There are context in which this can be genuinely useful. For example:
- rendering full object structures in highlighted hover data (markdown), e.g. `{ foo = string, bar = set(number) }`
- template files, which are effectively the inner part of a template expression, i.e. the `...` in `attr = "${...}"` - see https://github.com/hashicorp/vscode-terraform/issues/496 / https://github.com/hashicorp/vscode-terraform/issues/636
## Proposal
- [ ] Ensure we have this use case covered by tests
- [ ] Document this use case clearly in the Readme
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.