fix: trying to fix error in matching code

This commit is contained in:
Max Richter
2025-09-28 14:40:29 +02:00
parent fb0b80be78
commit 57ea1f6e3e
12 changed files with 39 additions and 14 deletions

View File

@@ -1,5 +1,7 @@
package template
import "fmt"
// CompileTemplate scans once, emitting:
// - data blocks: inner content between a line that's exactly "{" and a line that's exactly "}"
// - matching blocks: gaps between data blocks (excluding the brace lines themselves)
@@ -33,6 +35,7 @@ func CompileTemplate(templateSource string) ([]Block, error) {
if curlyIndex == 0 && nextCurlyIndex == 1 {
if i > start {
fmt.Printf("BLockContent 1: %q\n", template.Slice(start, i).String())
block, err := ParseTemplateBlock(template.Slice(start, i), blockType)
if err != nil {
return nil, NewErrorf("cannot parse block @pos -> %w", err).WithPosition(start, i)
@@ -42,6 +45,7 @@ func CompileTemplate(templateSource string) ([]Block, error) {
start = i
blockType = DataBlock
} else if curlyIndex == 1 && nextCurlyIndex == 0 {
fmt.Printf("BLockContent 2: %q\n", template.Slice(start, i).String())
if i > start {
block, err := ParseTemplateBlock(template.Slice(start, i), blockType)
if err != nil {