fix: most of the template blocks
This commit is contained in:
@@ -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)
|
||||
}
|
||||
|
Reference in New Issue
Block a user