feat: some updates

This commit is contained in:
Max Richter
2025-09-24 18:18:57 +02:00
parent b3c01bb43d
commit 26c303d9cf
32 changed files with 464 additions and 263 deletions

38
template/blocks_short.go Normal file
View File

@@ -0,0 +1,38 @@
package template
import (
"fmt"
"strings"
)
func parseShortTemplate(input string) (Block, error) {
split := strings.Split(cleanTemplate(input), "|")
if len(split) < 1 {
return Block{}, fmt.Errorf("invalid short template")
}
block := Block{
Type: DataBlock,
Path: strings.TrimSpace(split[0]),
Codec: CodecText,
content: input,
}
if len(split) > 1 {
optionSplit := strings.SplitSeq(split[1], ",")
for option := range optionSplit {
switch strings.TrimSpace(option) {
case "number":
block.Codec = CodecNumber
case "text":
block.Codec = CodecText
case "hashtags":
block.Codec = CodecHashtags
default:
return block, fmt.Errorf("unknown codec option: %s", option)
}
}
}
return block, nil
}