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

@@ -1,6 +1,7 @@
package template_test
import (
"fmt"
"testing"
"git.max-richter.dev/max/marka/registry"
@@ -20,6 +21,10 @@ func TestExtractBlocks(t *testing.T) {
t.FailNow()
}
for i, b := range templateBlocks {
fmt.Printf("Block#%d: %q\n", i, b.GetContent())
}
expected := []template.Block{
{
Type: template.MatchingBlock,
@@ -58,14 +63,11 @@ func TestExtractBlocks(t *testing.T) {
{Type: template.MatchingBlock},
{Type: template.DataBlock, Path: "name", Codec: "text"},
{Type: template.MatchingBlock},
{Type: template.DataBlock, Path: "keywords", Codec: "hashtags", Optional: true},
{Type: template.MatchingBlock},
{Type: template.DataBlock, Path: "description", Codec: "text"},
{Type: template.MatchingBlock},
{Type: template.DataBlock, Path: "recipeIngredient", Codec: "list", ListTemplate: "- { . }"},
{Type: template.MatchingBlock},
{Type: template.DataBlock, Path: "recipeInstructions", Codec: "list", ListTemplate: "{ @index }. { . }"},
{Type: template.MatchingBlock},
}
if len(templateBlocks) != len(expected) {