Add {..path} references: render a node from elsewhere in the merged data root

This commit is contained in:
lilleman
2026-06-09 00:11:17 +02:00
parent 8db65ac598
commit 18de1b7004
4 changed files with 246 additions and 4 deletions
+5 -1
View File
@@ -13,7 +13,8 @@ import (
// a node keyed by its base name (address.json -> "address"); each subdirectory
// becomes a nested group, so folders turn into dot-path segments. Paths are
// merged left to right: matching groups merge by their children, and any other
// clash (a leaf, or a leaf-vs-group) is won by the last directory loaded.
// clash (a leaf, or a leaf-vs-group) is won by the last directory loaded. Once
// merged, linkRefs binds every {..path} reference against the final tree.
func loadData(paths []string) (map[string]node, error) {
root := map[string]node{}
for _, p := range paths {
@@ -26,6 +27,9 @@ func loadData(paths []string) (map[string]node, error) {
if len(root) == 0 {
return nil, fmt.Errorf("no .json data found in %v", paths)
}
if err := linkRefs(root); err != nil {
return nil, err
}
return root, nil
}