fix: most of the template blocks

This commit is contained in:
Max Richter
2025-09-30 19:28:56 +02:00
parent d35f3e5e2e
commit 2a1572f99d
20 changed files with 210 additions and 187 deletions

View File

@@ -20,21 +20,27 @@ func ParseBlock(input string, block template.Block) (any, error) {
case template.CodecHashtags:
return Keywords(input, block)
}
return nil, fmt.Errorf("unknown codec: %s", block.Codec)
fmt.Printf("%#v\n", block)
return nil, fmt.Errorf("unknown codec '%s'", block.Codec)
}
func Parse(matches []matcher.Block) (any, error) {
var result any
for _, m := range matches {
for i, m := range matches {
if m.Block.Path == "@index" {
continue
}
input := m.GetContent()
value, err := ParseBlock(input, m.Block)
var blockIdentifier any
blockIdentifier = m.Block.Path
if blockIdentifier == "" {
blockIdentifier = fmt.Sprintf("#%d", i)
}
if err != nil {
return nil, fmt.Errorf("failed to parse block(%s): %w", m.Block.Path, err)
return nil, fmt.Errorf("failed to parse block(%s) -> %w", blockIdentifier, err)
}
result = utils.SetPathValue(m.Block.Path, value, result)
}