This commit is contained in:
Max Richter
2025-09-25 16:41:26 +02:00
parent 3f0d25f935
commit b13d5015f4
75 changed files with 3881 additions and 141 deletions

View File

@@ -19,8 +19,7 @@ func parseShortTemplate(input string) (Block, error) {
}
if len(split) > 1 {
optionSplit := strings.SplitSeq(split[1], ",")
for option := range optionSplit {
for option := range strings.SplitSeq(split[1], ",") {
switch strings.TrimSpace(option) {
case "number":
block.Codec = CodecNumber
@@ -28,6 +27,8 @@ func parseShortTemplate(input string) (Block, error) {
block.Codec = CodecText
case "hashtags":
block.Codec = CodecHashtags
case "optional":
block.Optional = true
default:
return block, fmt.Errorf("unknown codec option: %s", option)
}

View File

@@ -30,13 +30,13 @@ func TestExtractBlocks(t *testing.T) {
Path: ".",
Fields: []template.BlockField{
{
Path: "@type",
Path: "_type",
},
{
Path: "image",
},
{
Path: "author.@type",
Path: "author._type",
},
{
Path: "author.name",

View File

@@ -1,6 +1,6 @@
module git.max-richter.dev/max/marka/template
go 1.25.1
go 1.24.7
require (
git.max-richter.dev/max/marka/registry v0.0.0-20250819170608-69c2550f448e

View File

@@ -20,6 +20,7 @@ type Block struct {
Codec CodecType
ListTemplate string
Fields []BlockField
Optional bool
Value any
content string
}