summaryrefslogtreecommitdiff
path: root/hclwrite
diff options
context:
space:
mode:
authorKazuma Watanabe <watassbass@gmail.com>2019-08-10 06:00:04 +0900
committerMartin Atkins <mart@degeneration.co.uk>2019-08-09 14:00:04 -0700
commit72d32879a5c5db881136f801b9efedf19813c081 (patch)
tree1972fab87beb80ead3f17d5ed9c07bcef5145c0b /hclwrite
parent65731f3310963019707cb1ee851b7c12779a4f62 (diff)
hclwrite: Do not add spaces before template control sequences
Diffstat (limited to 'hclwrite')
-rw-r--r--hclwrite/format.go2
-rw-r--r--hclwrite/format_test.go4
2 files changed, 5 insertions, 1 deletions
diff --git a/hclwrite/format.go b/hclwrite/format.go
index ded7fb4..7111ebd 100644
--- a/hclwrite/format.go
+++ b/hclwrite/format.go
@@ -317,7 +317,7 @@ func spaceAfterToken(subject, before, after *Token) bool {
return true
// Don't add spaces between interpolated items
- case subject.Type == hclsyntax.TokenTemplateSeqEnd && after.Type == hclsyntax.TokenTemplateInterp:
+ case subject.Type == hclsyntax.TokenTemplateSeqEnd && (after.Type == hclsyntax.TokenTemplateInterp || after.Type == hclsyntax.TokenTemplateControl):
return false
case tokenBracketChange(subject) > 0:
diff --git a/hclwrite/format_test.go b/hclwrite/format_test.go
index a918290..7422769 100644
--- a/hclwrite/format_test.go
+++ b/hclwrite/format_test.go
@@ -80,6 +80,10 @@ func TestFormat(t *testing.T) {
`a = "${b}${c}${d} ${e}"`,
},
{
+ `"%{if true}${var.foo}%{endif}"`,
+ `"%{if true}${var.foo}%{endif}"`,
+ },
+ {
`b{}`,
`b {}`,
},