Skip to content

Commit

Permalink
don't interpolate literals when in single-quote mode
Browse files Browse the repository at this point in the history
  • Loading branch information
jippi committed Feb 11, 2024
1 parent bc18409 commit e59794f
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions pkg/parser/parser.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,9 +65,18 @@ func (p *Parser) Parse() (*ast.Document, error) {
val.Position.File = p.filename

if val.Active {
val.Interpolated, err = doc.Interpolate(val)
if err != nil {
return nil, err
switch {
// In "single”-quote mode we skip interpolation
// and use the string as-is
case val.Quote.Is(token.SingleQuotes.Rune()):
val.Interpolated = val.Literal

// In "double" and "no"-quote mode, we interpolate
default:
val.Interpolated, err = doc.Interpolate(val)
if err != nil {
return nil, err
}
}
}

Expand Down

0 comments on commit e59794f

Please sign in to comment.