feat: renderer
This commit is contained in:
@@ -7,13 +7,13 @@ import (
|
||||
|
||||
"git.max-richter.dev/max/marka/parser/decoders"
|
||||
"git.max-richter.dev/max/marka/parser/matcher"
|
||||
"git.max-richter.dev/max/marka/parser/utils"
|
||||
"git.max-richter.dev/max/marka/registry"
|
||||
"git.max-richter.dev/max/marka/template"
|
||||
"git.max-richter.dev/max/marka/testdata"
|
||||
)
|
||||
|
||||
func TestParseBaguette(t *testing.T) {
|
||||
recipeMd := utils.ReadTestDataFile(t, "baguette.md")
|
||||
recipeMd := testdata.Read(t, "baguette/input.md")
|
||||
|
||||
templateContent, err := registry.GetTemplate("Recipe")
|
||||
if err != nil {
|
||||
@@ -25,7 +25,7 @@ func TestParseBaguette(t *testing.T) {
|
||||
t.Fatalf("Err: %s", err)
|
||||
}
|
||||
|
||||
matches := matcher.MatchBlocksFuzzy(recipeMd, blocks, 0.3)
|
||||
matches := matcher.MatchBlocksFuzzy(string(recipeMd), blocks, 0.3)
|
||||
parsed, err := decoders.Parse(matches)
|
||||
if err != nil {
|
||||
t.Fatalf("Err: %s", err)
|
||||
|
@@ -4,6 +4,7 @@ import (
|
||||
"fmt"
|
||||
|
||||
"git.max-richter.dev/max/marka/parser/utils"
|
||||
renderUtils "git.max-richter.dev/max/marka/renderer/utils"
|
||||
"git.max-richter.dev/max/marka/template"
|
||||
"go.yaml.in/yaml/v4"
|
||||
)
|
||||
@@ -17,12 +18,15 @@ func Yaml(input string, block template.Block) (value any, error error) {
|
||||
|
||||
var out any
|
||||
for _, f := range block.Fields {
|
||||
if f.Hidden {
|
||||
continue
|
||||
}
|
||||
if f.CodecType == template.CodecConst {
|
||||
if f.Value != nil {
|
||||
out = utils.SetPathValue(f.Path, f.Value, out)
|
||||
}
|
||||
} else {
|
||||
if value, ok := res[f.Path]; ok {
|
||||
if value, ok := renderUtils.GetValueFromPath(res, f.Path); ok {
|
||||
out = utils.SetPathValue(f.Path, value, out)
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user