diff options
author | Thomas Voss <mail@thomasvoss.com> | 2023-09-11 05:10:54 +0200 |
---|---|---|
committer | Thomas Voss <mail@thomasvoss.com> | 2023-09-11 05:10:54 +0200 |
commit | 8bbf31f9f779ae9958ff3324f0f7735aa366f7bc (patch) | |
tree | 0f6d6f70b2758df577dc8cd47e74b5e8636c1aba /parser/parser.go | |
parent | 977f794ab8b28d7462fd0e85eee7d4343f946d3a (diff) |
Add the ‘=’ node for whitespace trimming
Diffstat (limited to 'parser/parser.go')
-rw-r--r-- | parser/parser.go | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/parser/parser.go b/parser/parser.go index f55a135..0fc0037 100644 --- a/parser/parser.go +++ b/parser/parser.go @@ -14,6 +14,7 @@ type nodeType uint const ( Normal nodeType = iota Tagless + TaglessTrim Text ) @@ -66,8 +67,8 @@ func (reader *reader) parseNode() (node AstNode, err error) { } switch r { - case '-': - return reader.parseText() + case '-', '=': + return reader.parseText(r == '=') case '>': node.Newline = true if _, err = reader.readRune(); err != nil { @@ -153,13 +154,18 @@ func (reader *reader) parseNodeName() (string, error) { return sb.String(), nil } -func (reader *reader) parseText() (AstNode, error) { +func (reader *reader) parseText(trim bool) (AstNode, error) { if _, err := reader.readRune(); err != nil { return AstNode{}, err } sb := strings.Builder{} - node := AstNode{Type: Tagless} + node := AstNode{} + if trim { + node.Type = TaglessTrim + } else { + node.Type = Tagless + } loop: for { |