Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support 'quotedTemplate' in addition to 'StrLit' in block labels. #600

Open
semtexzv opened this issue Mar 24, 2023 · 0 comments
Open

Support 'quotedTemplate' in addition to 'StrLit' in block labels. #600

semtexzv opened this issue Mar 24, 2023 · 0 comments

Comments

@semtexzv
Copy link

Currently, block label can be either identifier or string literal. I kind of want to support following pattern in a DSL I'm working on

template {
    repeat = 10
    vars {
        prefix = "Hello"
    }
    generate {
        object "${vars.prefix}-${repeat}" {
            
        }
    }
}

But the HCL spec explicitly only allows strings or literals as object keys.

Lifting the quotedTemplate from just subpattern of TemplateExpr into a rule that could be used as block label would greatly extend the usability, and reduce the need for patterns like for_each in terraform.

TL;DR: In Syntax spec:
Replace

Block        = Identifier (StringLit|Identifier)* "{" Newline Body "}" Newline;

with:

Block        = Identifier (StringLit|Identifier|QuotedTemplate)* "{" Newline Body "}" Newline;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant