One fence sequence over a node scope, and inline templates reject the folder sigils
This commit is contained in:
+11
-2
@@ -111,14 +111,23 @@ func linkTemplateRefs(folder []string, path string, t *template, root map[string
|
||||
}
|
||||
|
||||
// linkNodeRefs binds the references in an inline node's templates against the
|
||||
// loaded tree. The node has no folder of its own, so every sigil is root-relative:
|
||||
// / and . mean the root, .. has no folder above it.
|
||||
// loaded tree. An inline template sits in no folder, so . and .. name nothing and
|
||||
// are rejected for the root spelling they would otherwise silently mean.
|
||||
func linkNodeRefs(n node, root map[string]node) error {
|
||||
return eachNode(n, "template", func(path string, m node) error {
|
||||
t, ok := m.(*template)
|
||||
if !ok {
|
||||
return nil
|
||||
}
|
||||
for _, name := range refTokens(t.format) {
|
||||
sigil, rest, err := refShape(name)
|
||||
if err != nil {
|
||||
return fmt.Errorf("%s: reference {%s}: %w", path, name, err)
|
||||
}
|
||||
if sigil != "/" {
|
||||
return fmt.Errorf("%s: reference {%s}: an inline template has no folder; write {/%s}", path, name, rest)
|
||||
}
|
||||
}
|
||||
return linkTemplateRefs(nil, path, t, root)
|
||||
})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user