wip
This commit is contained in:
@@ -13,8 +13,7 @@ import (
|
||||
const emptyBlock = "\uE000"
|
||||
|
||||
func fixRenderedBlock(input string) string {
|
||||
input = strings.ReplaceAll(input, "'@type':", "@type:")
|
||||
input = strings.ReplaceAll(input, "'@context':", "@context:")
|
||||
input = strings.ReplaceAll(input, "'_type':", "_type:")
|
||||
if len(input) == 0 {
|
||||
return emptyBlock
|
||||
}
|
||||
|
@@ -1,6 +1,6 @@
|
||||
module git.max-richter.dev/max/marka/renderer
|
||||
|
||||
go 1.25.1
|
||||
go 1.24.7
|
||||
|
||||
require (
|
||||
git.max-richter.dev/max/marka/parser v0.0.0-20250819170608-69c2550f448e
|
||||
|
@@ -18,10 +18,10 @@ func RenderFile(rawJSON []byte) ([]byte, error) {
|
||||
return nil, fmt.Errorf("failed to parse JSON: %w", err)
|
||||
}
|
||||
|
||||
// 2) extract type from "@type" Property
|
||||
contentType, ok := data["@type"].(string)
|
||||
// 2) extract type from "_type" Property
|
||||
contentType, ok := data["_type"].(string)
|
||||
if !ok || contentType == "" {
|
||||
return nil, fmt.Errorf("JSON does not contain a valid '@type' property")
|
||||
return nil, fmt.Errorf("JSON does not contain a valid '_type' property")
|
||||
}
|
||||
|
||||
// 3) get the template from the registry
|
||||
|
@@ -41,10 +41,10 @@ func TestRenderFile_MissingType(t *testing.T) {
|
||||
rawJSON := []byte(`{"name": "Test"}`)
|
||||
_, err := renderer.RenderFile(rawJSON)
|
||||
if err == nil {
|
||||
t.Fatal("expected error for missing @type, got nil")
|
||||
t.Fatal("expected error for missing _type, got nil")
|
||||
}
|
||||
if !strings.Contains(err.Error(), "JSON does not contain a valid '@type' property") {
|
||||
t.Errorf("expected missing @type error, got: %v", err)
|
||||
if !strings.Contains(err.Error(), "JSON does not contain a valid '_type' property") {
|
||||
t.Errorf("expected missing _type error, got: %v", err)
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user