Skip to content
This repository has been archived by the owner on Mar 20, 2024. It is now read-only.

Multiline string support #15

Open
spenceral opened this issue Apr 23, 2019 · 2 comments
Open

Multiline string support #15

spenceral opened this issue Apr 23, 2019 · 2 comments

Comments

@spenceral
Copy link

Hello! Can hclencoder encode multiline strings? If not, can I submit a PR that will not quote strings that are prefixed with <<? I believe that allow multiline strings to be encoded properly as long as the user has submitted a string in heredoc format.

@rodaine
Copy link
Owner

rodaine commented Apr 23, 2019

Howdy! I'm not sure if we have any tests for multiline strings, but if it's not encoding them properly (or if it's slapping \n everywhere), it's probably best to support the heredoc format. I don't think we should treat strings beginning with << as special though.

If you want to take a stab at this, I'd recommend detecting if a string contains \n before encoding, if it does, output in a heredoc format instead, with some default sentinel (perhaps EOF) which can be overridden with an hcle struct tag. Thoughts?

@spenceral
Copy link
Author

As far as I can tell, it is not encoding multiline strings properly as it handling the string like any other primitive string, e.g.

foo = "asdf
hjkl"

Rather than encoding it in the heredoc format, e.g.

foo = <<EOF
asdf
hjkl
EOF

Your approach sounds better than looking for a "<<" prefix. I'll take a stab at it.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants