From e59794fe4509eacb47987df87283ef6fedc5f5e1 Mon Sep 17 00:00:00 2001 From: Christian Winther Date: Sun, 11 Feb 2024 01:00:23 +0100 Subject: [PATCH] don't interpolate literals when in single-quote mode --- pkg/parser/parser.go | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/pkg/parser/parser.go b/pkg/parser/parser.go index bc68924..6dafb04 100644 --- a/pkg/parser/parser.go +++ b/pkg/parser/parser.go @@ -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 + } } }