Skip to content

Raw Strings #788

@tmccombs

Description

@tmccombs

There are several cases where it would be desirable to have a string format that makes it easier to create string literal without needing to escape special characters. In particular, regexes, and template strings passed to something else, where I have a lot of "${" that shouldn't be interpolated by hcl itself.

Heredoc strings avoid needing to escape backslashes, but require a newline at the end. Which can be problematic. And it doesn't help with avoiding template interpolation.

I propose adding some form of raw string literal syntax. This could be any of the following:

  • surround the text with a matching amount of backtics for example
    x = `single`
    y = ``double``
    
    Or maybe only use single backtics
  • something like rusts raw strings: ##"number of #s must match"##
  • a prefix like python raw strings: r"raw". Although that is problematic if you need to use " in it

Metadata

Metadata

Assignees

No one assigned

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions