wip
This commit is contained in:
@@ -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)
|
||||
}
|
||||
|
@@ -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",
|
||||
|
@@ -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
|
||||
|
@@ -20,6 +20,7 @@ type Block struct {
|
||||
Codec CodecType
|
||||
ListTemplate string
|
||||
Fields []BlockField
|
||||
Optional bool
|
||||
Value any
|
||||
content string
|
||||
}
|
||||
|
Reference in New Issue
Block a user