Load shipped categories before binding, panic on an index that misses a read, and name the index entry and unloaded category plainly

This commit is contained in:
2026-10-03 17:20:36 +02:00
committed by Lillem4n
parent 81bb979164
commit 8b3bbc4003
10 changed files with 70 additions and 85 deletions
+4 -8
View File
@@ -34,7 +34,8 @@ func (f *Generator) NewTemplate(input string) (*Template, error) {
}
f.mu.Lock()
defer f.mu.Unlock()
if err := inlineBinding(n, "template", &f.root).bind(); err != nil {
loadShipped(&f.root, unloadedReads(&f.root, nil, inlineScope(n, "template")))
if err := inlineBinding(n, "template", f.root.children).bind(); err != nil {
return nil, fmt.Errorf("fejkdata: %w", err)
}
return &Template{g: f, n: n}, nil
@@ -148,16 +149,11 @@ func inputValue(input string) (any, error) {
return raw, nil
}
func inlineBinding(n node, label string, root *folder) binding {
func inlineBinding(n node, label string, root map[string]node) binding {
scope := inlineScope(n, label)
return binding{
scope: scope,
link: func() error {
if err := loadShipped(root, shippedReads(root, nil, scope)); err != nil {
return err
}
return linkNodeRefs(scope, root.children)
},
link: func() error { return linkNodeRefs(scope, root) },
scopeFence: func() error {
if t, isTemplate := n.(*template); isTemplate && t.drawGroup != "" {
return fmt.Errorf("%s: drawGroup %q names nothing, since nothing can reference an inline template; drop it", label, t.drawGroup)