hcl/hclwrite
Martin Atkins bafa0c5ace hcl/hclsyntax: Accept single-line block definitions
This relaxes our previous spec to include a special form from HCL 1:

    foo { bar = baz }

Although we normally require each argument to be on a line of its own, as
a special case we allow a block to be defined with a single nested
argument all on one line.

Only one nested argument definition is allowed, and a nested block
definition like "foo { bar {} }" is also disallowed in order to force the
more-readable split of bar {} onto a line of its own.

This is a pragmatic addition for broader compatibility with HCL 1-oriented
input. This single-line usage is not considered idiomatic HCL 2 and may
in future be undone by the formatter, though for now it is left as-is
aside from the spacing around the braces.

This also changes the behavior of the source code formatter to include
spaces on both sides of braces. This mimicks the formatting behavior of
HCL 1 for this situation, and (subjectively) reads better even for other
one-line braced expressions like object constructors and object for
expressions.
2018-12-14 13:45:03 -08:00
..
ast_attribute.go hclwrite: Split Attribute and Block into their own source files 2018-11-03 09:21:43 -07:00
ast_block.go hclwrite: Support for creating new blocks and clearing bodies 2018-11-04 01:13:13 +00:00
ast_body_test.go hclwrite: Implement Body.SetAttributeTraversal 2018-11-04 02:09:35 +00:00
ast_body.go hclwrite: Expression.RenameVariablePrefix 2018-11-04 04:17:03 +00:00
ast_expression.go hclwrite: Expression.RenameVariablePrefix 2018-11-04 04:17:03 +00:00
ast_test.go hclwrite: Simplify internal data structures 2018-08-01 08:46:31 -07:00
ast.go hclwrite: NewEmptyFile function 2018-11-03 20:45:25 +00:00
doc.go hclwrite: Split Attribute and Block into their own source files 2018-11-03 09:21:43 -07:00
examples_test.go hcl/hclsyntax: Accept single-line block definitions 2018-12-14 13:45:03 -08:00
format_test.go hcl/hclsyntax: Accept single-line block definitions 2018-12-14 13:45:03 -08:00
format.go hcl/hclsyntax: Accept single-line block definitions 2018-12-14 13:45:03 -08:00
generate_test.go hcl/hclsyntax: Accept single-line block definitions 2018-12-14 13:45:03 -08:00
generate.go hclwrite: Implement Body.SetAttributeTraversal 2018-11-04 02:09:35 +00:00
native_node_sorter.go Move the zcl package and its two parsing subpackages to "hcl" names 2017-09-11 16:40:37 -07:00
node.go hclwrite: Support for creating new blocks and clearing bodies 2018-11-04 01:13:13 +00:00
parser_test.go hclwrite: Simplify internal data structures 2018-08-01 08:46:31 -07:00
parser.go hclwrite: Expression.RenameVariablePrefix 2018-11-04 04:17:03 +00:00
public.go hclwrite: Adjust token spacing automatically when writing 2018-08-25 12:15:40 -07:00
round_trip_test.go hclwrite: Make File and Tokens implement io.WriterTo 2018-11-03 20:19:56 +00:00
tokens.go hclwrite: Make File and Tokens implement io.WriterTo 2018-11-03 20:19:56 +00:00