Backtestshugorun-20261009-153657#15373
Support relative path calls in partials
Our patch was judged better than the merged fix.
In this judgment, Patch A = our agent, Patch B = the merged fix.
Both patches take the same basic approach. They resolve `./` and `../` names against the calling partial's directory before lookup and before the partialCached cache key is computed. Both also add a `decoratorOwner` link so that `with partial` decorator inner blocks resolve against the template that wrote them. The differences are in robustness.
1. **Deferred-template collisions.** Patch A changes the deferred-template hash in `handleWith` to include the owner's partial directory. Without this, two partials in different directories with identical `templates.Defer` bodies (e.g. `{{ partial "./item.html" . }}`) share one deferred template ID. Only the first registration's PathInfo is kept, so the second resolves against the wrong directory. Patch B leaves the hash unchanged, so it has this bug. Patch A's `TestIncludeRelativePathDefer` exercises this case directly.
2. **Deferred-template ownership.** Patch A sets `decoratorOwner: owner` on deferred templates, which also correctly follows deferred blocks nested in decorators. Patch B instead copies `owner.category` onto the deferred TemplInfo, which was previously left at its zero value. That changes a field other code may consult and adds risk. It also copies `owner.decoratorOwner`, which works but is less direct.
3. **Edge-case handling.** Patch B uses an unchecked type assertion `cur.CurrentTemplateInfoOps.(*TemplInfo)`, which can panic. Patch A uses the comma-ok form. Patch A also rejects names that don't name a file (`./`, `..`). It verifies that the resolved path stays under the partials root, and it handles the legacy `layouts/partials` directory and inline-defined partials, with tests for each.
4. **Tests.** Patch A's suite is broader: cache-key separation, legacy directory, inline partials, decorators, defer, and table-driven error cases. Patch B's tests cover the main paths, decorator, defer and two error cases, but miss the hash collision.
Patch B adds documentation, which is a nice touch but neutral under the scope criterion. Overall, Patch A is more correct and better tested.
The judge saw only the two patches, labelled A and B in random order, with issue links and version numbers removed. The reasoning above is shown verbatim.
Solve
32m 40s
Wall-clock time in the container
Full test suite
No new failures
919 passed · 28 skipped · 947 total
Contamination audit
Clean
No sign the agent saw the real fix
Patch size
310vs 204 merged
Changed lines, ours vs merged
The issue
View on GitHubRight now partial calls only supports path relative to layout/partials and themes/<THEME>/layouts/partials/*<PARTIALNAME> (taken from the documentation).
This is fine when we have few partials but can become a pain if we need to organize them in subdirectories.
What i propose is to add support for relative paths like in this example :
{{ partial "./foo" ... }}
{{ partial "../bah" ... }}
Why ?
Having this feature could be beneficial in a lot or ways :
- it avoid us having to remember and write the full partial path when it's not needed (for example utility partials that are only called and only used by a on partial)
- It could allow us to reorganize partials way more easily, as relative paths would full path independent
How to implement
If the path in a partial call starts with "./" or "../", it's a relative path. Otherwise it's an "absolute" path (relative to layout/partials).
I'm against adding the current directory of the current partial to the lookup search directly though, as theme and site authors currently assume this would call to the partial root directory. Perhaps we could add this to the future, if my proposal is adopted by the community.
The two patches
tpl/partials/partials.goindex f0906fb83..6333653d4 100644@@ -111,14 +111,34 @@ func (ns *Namespace) Include(ctx context.Context, name string, contextList ...an } func (ns *Namespace) include(ctx context.Context, name string, dataList ...any) includeResult {- v, err := ns.lookup(name)+ v, err := ns.lookup(ctx, name) if err != nil { return includeResult{err: err} } return ns.doInclude(ctx, "", v, dataList...) } -func (ns *Namespace) lookup(name string) (*tplimpl.TemplInfo, error) {+// resolveName resolves a partial name relative to the calling partial if+// it starts with "./" or "../". Other names are returned as is.+func (ns *Namespace) resolveName(ctx context.Context, name string) (string, error) {+ if !tplimpl.IsRelativePartialName(name) {+ return name, nil+ }+ var caller *tplimpl.TemplInfo+ if current := tpl.Context.CurrentTemplate.Get(ctx); current != nil {+ caller, _ = current.CurrentTemplateInfoOps.(*tplimpl.TemplInfo)+ }+ if caller == nil {+ return "", fmt.Errorf("relative partial name %q can only be used from within a partial", name)+ }+ return caller.ResolveRelativePartialName(name)+}++func (ns *Namespace) lookup(ctx context.Context, name string) (*tplimpl.TemplInfo, error) {+ name, err := ns.resolveName(ctx, name)+ if err != nil {+ return nil, err+ } if strings.HasPrefix(name, "partials/") { // This is most likely not what the user intended. // This worked before Hugo 0.146.0.@@ -181,6 +201,10 @@ func (ns *Namespace) doInclude(ctx context.Context, key string, templ *tplimpl.T // Note that ctx is provided by Hugo, not the end user. func (ns *Namespace) IncludeCached(ctx context.Context, name string, context any, variants ...any) (any, error) { start := time.Now()+ name, err := ns.resolveName(ctx, name)+ if err != nil {+ return nil, err+ } keyString := name if len(variants) > 0 { key := partialCacheKey{@@ -191,7 +215,7 @@ func (ns *Namespace) IncludeCached(ctx context.Context, name string, context any } depsManagerIn := tpl.Context.GetDependencyManagerInCurrentScope(ctx)- ti, err := ns.lookup(name)+ ti, err := ns.lookup(ctx, name) if err != nil { return nil, err }tpl/partials/partials_integration_test.goindex 72b5f62a5..0b45bb4eb 100644@@ -428,3 +428,221 @@ baseURL = 'http://example.com/' b.AssertFileContent("public/index.html", "42|") }++func TestIncludeRelativePath(t *testing.T) {+ t.Parallel()++ files := `+-- hugo.toml --+baseURL = 'http://example.com/'+disableKinds = ["section", "taxonomy", "term", "sitemap", "RSS"]+-- layouts/home.html --+home: {{ partial "components/card/card.html" . }}+-- layouts/_partials/components/card/card.html --+card[{{ partial "./title.html" . }}|{{ partial "./parts/body" . }}|{{ partialCached "../shared.html" . }}|{{ partials.Include "./parts/../title.html" . }}]+-- layouts/_partials/components/card/title.html --+card-title+-- layouts/_partials/components/card/parts/body.html --+body[{{ partial "../title.html" . }}|{{ partial "../../../root.html" . }}]+-- layouts/_partials/components/shared.html --+shared+-- layouts/_partials/root.html --+root+-- layouts/_partials/title.html --+root-title+`++ b := hugolib.Test(t, files)++ b.AssertFileContent("public/index.html", "home: card[card-title|body[card-title|root]|shared|card-title]")+}++func TestIncludeRelativePathLegacyPartialsDir(t *testing.T) {+ t.Parallel()++ files := `+-- hugo.toml --+baseURL = 'http://example.com/'+disableKinds = ["section", "taxonomy", "term", "sitemap", "RSS"]+-- layouts/index.html --+home: {{ partial "a/b.html" . }}+-- layouts/partials/a/b.html --+b[{{ partial "./c.html" . }}|{{ partial "../d.html" . }}]+-- layouts/partials/a/c.html --+c+-- layouts/partials/d.html --+d+`++ b := hugolib.Test(t, files)++ b.AssertFileContent("public/index.html", "home: b[c|d]")+}++func TestIncludeRelativePathInlinePartial(t *testing.T) {+ t.Parallel()++ files := `+-- hugo.toml --+baseURL = 'http://example.com/'+disableKinds = ["section", "taxonomy", "term", "sitemap", "RSS"]+-- layouts/home.html --+home: {{ partial "a/inline.html" . }}+{{ define "_partials/a/inline.html" }}inline[{{ partial "./b.html" . }}]{{ end }}+-- layouts/_partials/a/b.html --+b+`++ b := hugolib.Test(t, files)++ b.AssertFileContent("public/index.html", "home: inline[b]")+}++// Relative names in partialCached must be resolved before computing the cache key,+// so the same relative name in different directories does not share a cache entry.+func TestIncludeCachedRelativePathCacheKey(t *testing.T) {+ t.Parallel()++ files := `+-- hugo.toml --+baseURL = 'http://example.com/'+disableKinds = ["section", "taxonomy", "term", "sitemap", "RSS"]+-- layouts/home.html --+home: {{ partial "a/main.html" . }}|{{ partial "b/main.html" . }}+-- layouts/_partials/a/main.html --+{{ partialCached "./item.html" . }}+-- layouts/_partials/a/item.html --+a-item+-- layouts/_partials/b/main.html --+{{ partialCached "./item.html" . }}+-- layouts/_partials/b/item.html --+b-item+`++ b := hugolib.Test(t, files)++ b.AssertFileContent("public/index.html", "home: a-item\n|b-item")+}++func TestIncludeRelativePathDecorator(t *testing.T) {+ t.Parallel()++ files := `+-- hugo.toml --+baseURL = 'http://example.com/'+disableKinds = ["section", "taxonomy", "term", "sitemap", "RSS"]+-- layouts/home.html --+home: {{ partial "a/b/page.html" . }}+-- layouts/_partials/a/b/page.html --+{{ with partial "../wrap.html" . }}{{ partial "./content.html" . }}{{ end }}+-- layouts/_partials/a/wrap.html --+wrap[{{ inner . }}]+-- layouts/_partials/a/b/content.html --+content+`++ b := hugolib.Test(t, files)++ b.AssertFileContent("public/index.html", "home: wrap[content]")+}++func TestIncludeRelativePathDefer(t *testing.T) {+ t.Parallel()++ files := `+-- hugo.toml --+baseURL = 'http://example.com/'+disableKinds = ["section", "taxonomy", "term", "sitemap", "RSS"]+-- layouts/home.html --+home: {{ partial "a/page.html" . }}|{{ partial "b/page.html" . }}+-- layouts/_partials/a/page.html --+{{ with (templates.Defer (dict "key" "a")) }}{{ partial "./item.html" . }}{{ end }}+-- layouts/_partials/b/page.html --+{{ with (templates.Defer (dict "key" "b")) }}{{ partial "./item.html" . }}{{ end }}+-- layouts/_partials/a/item.html --+item-a+-- layouts/_partials/b/item.html --+item-b+`++ b := hugolib.Test(t, files)++ b.AssertFileContent("public/index.html", "home: item-a|item-b")+}++func TestIncludeRelativePathErrors(t *testing.T) {+ t.Parallel()++ for _, test := range []struct {+ name string+ files string+ want string+ }{+ {+ name: "outside partial",+ files: `+-- layouts/home.html --+{{ partial "./foo.html" . }}+-- layouts/_partials/foo.html --+foo+`,+ want: `relative partial name "./foo.html" can only be used from within a partial`,+ },+ {+ name: "outside partial in decorator",+ files: `+-- layouts/home.html --+{{ with partial "wrap.html" . }}{{ partial "./foo.html" . }}{{ end }}+-- layouts/_partials/wrap.html --+{{ inner . }}+-- layouts/_partials/foo.html --+foo+`,+ want: `relative partial name "./foo.html" can only be used from within a partial`,+ },+ {+ name: "escapes partials root",+ files: `+-- layouts/home.html --+{{ partial "a.html" . }}+-- layouts/_partials/a.html --+{{ partial "../home.html" . }}+`,+ want: `relative partial name "../home.html" in "_partials/a.html" resolves to a path outside of the partials directory`,+ },+ {+ name: "directory name",+ files: `+-- layouts/home.html --+{{ partial "a/b.html" . }}+-- layouts/_partials/a/b.html --+{{ partial "./" . }}+-- layouts/_partials/a.html --+a+`,+ want: `relative partial name "./" in "_partials/a/b.html" does not name a partial`,+ },+ {+ name: "not found",+ files: `+-- layouts/home.html --+{{ partial "a/b.html" . }}+-- layouts/_partials/a/b.html --+{{ partial "./missing.html" . }}+`,+ want: `partial "a/missing.html" not found`,+ },+ } {+ t.Run(test.name, func(t *testing.T) {+ t.Parallel()+ files := `+-- hugo.toml --+baseURL = 'http://example.com/'+disableKinds = ["section", "taxonomy", "term", "sitemap", "RSS"]+` + test.files+ _, err := hugolib.TestE(t, files)+ qt.Assert(t, err, qt.IsNotNil)+ qt.Assert(t, err.Error(), qt.Contains, test.want)+ })+ }+}tpl/tplimpl/templatestore.goindex 4721c1f4a..5a748dcd1 100644@@ -263,6 +263,60 @@ type TemplInfo struct { // processing state. state processingState isLegacyMapped bool++ // Set for internal partial decorator templates; the template+ // in which the decorated with block was written.+ decoratorOwner *TemplInfo+}++// IsRelativePartialName reports whether name is a partial name+// relative to the calling partial, i.e. starting with "./" or "../".+func IsRelativePartialName(name string) bool {+ return strings.HasPrefix(name, "./") || strings.HasPrefix(name, "../")+}++// ResolveRelativePartialName resolves the relative partial name (see IsRelativePartialName)+// against the directory of this partial template and returns the+// name relative to the partials root, e.g. "foo/bar.html".+func (ti *TemplInfo) ResolveRelativePartialName(name string) (string, error) {+ owner := ti.relativePartialOwner()+ const root = "/" + containerPartials+ dir := owner.relativePartialDir()+ if dir == "" {+ return "", fmt.Errorf("relative partial name %q can only be used from within a partial, called from %q", name, owner.Name())+ }+ if base := path.Base(name); strings.HasSuffix(name, "/") || base == "." || base == ".." {+ return "", fmt.Errorf("relative partial name %q in %q does not name a partial", name, owner.Name())+ }+ resolved := path.Join(dir, name)+ if !strings.HasPrefix(resolved, root+"/") {+ return "", fmt.Errorf("relative partial name %q in %q resolves to a path outside of the partials directory", name, owner.Name())+ }+ return strings.TrimPrefix(resolved, root+"/"), nil+}++// relativePartialOwner returns the template in which the code of ti was written,+// following internal decorator and deferred templates back to their owner.+func (ti *TemplInfo) relativePartialOwner() *TemplInfo {+ owner := ti+ for owner.decoratorOwner != nil {+ owner = owner.decoratorOwner+ }+ return owner+}++// relativePartialDir returns the directory relative partial names in ti+// resolve against, e.g. "/_partials/foo", or "" if ti is not a partial.+func (ti *TemplInfo) relativePartialDir() string {+ const root = "/" + containerPartials+ if ti.category != CategoryPartial || ti.PathInfo == nil {+ return ""+ }+ dir := path.Dir(ti.PathInfo.Path())+ if dir != root && !strings.HasPrefix(dir, root+"/") {+ return ""+ }+ return dir } func (ti *TemplInfo) SubCategory() SubCategory {@@ -943,6 +997,8 @@ func (t *TemplateStore) addDeferredTemplate(owner *TemplInfo, name string, n *pa PathInfo: owner.PathInfo, D: owner.D, Template: templ,+ // Relative partial names in the deferred block resolve against the template it was written in.+ decoratorOwner: owner, }) return niltpl/tplimpl/templatetransform.goindex dcb59abe7..49514b590 100644@@ -301,6 +301,8 @@ func (c *templateTransformContext) handleWithPartial(withNode *parse.WithNode) { c.err = fmt.Errorf("failed to find internal partial decorator template %q after insertion", internalPartialName) return }+ // Relative partial names in the with block resolve against the template it was written in.+ ti.decoratorOwner = c.t cc := newTemplateTransformContext(ti, c.store, c.lookupFn) @@ -411,7 +413,9 @@ func (c *templateTransformContext) handleWith(withNode *parse.WithNode) { // The deferred template is parsed using the owner's escaping mode. Keep // identical bodies shared within that mode, but don't let HTML and plain // text templates register the same deferred template.- innerHash := hashing.XxHashFromStringHexEncoded(fmt.Sprintf("%t:%s", c.t.D.IsPlainText, s))+ // Relative partial names resolve against the owner's directory, so keep+ // identical bodies in partials in different directories apart.+ innerHash := hashing.XxHashFromStringHexEncoded(fmt.Sprintf("%t:%s:%s", c.t.D.IsPlainText, c.t.relativePartialOwner().relativePartialDir(), s)) deferredID := tpl.HugoDeferredTemplatePrefix + innerHash c.deferNodes[deferredID] = inner
docs/content/en/functions/partials/Include.mdindex 58acbcc7f..d42dacce0 100644@@ -74,5 +74,29 @@ To return a value from a _partial_ template, it must contain only one `return` s {{ return $result }} ``` +## Relative paths++{{< new-in 0.167.0 />}}++Within a _partial_ template, a path that begins with `./` or `../` is resolved relative to the directory of the calling _partial_ template. For example, given this structure:++```tree+layouts/+└── _partials/+ ├── cards/+ │ ├── card.html+ │ └── image.html+ └── footer.html+```++The "card" _partial_ template can call its sibling and the "footer" _partial_ template like this:++```go-html-template+{{ partial "./image.html" . }}+{{ partial "../footer.html" . }}+```++Relative paths are only supported from within _partial_ templates. Calling `partial "./foo.html"` from any other template, or with a path that resolves outside the `_partials` directory, is an error.+ [`return`]: /functions/go-template/return/ [breadcrumb navigation]: /content-management/sections/#ancestors-and-descendantsdocs/content/en/functions/partials/IncludeCached.mdindex eea5751e8..a58ee53e9 100644@@ -20,6 +20,8 @@ The `partialCached` function can offer significant performance gains for complex > > Hugo renders pages in parallel, and will render the _partial_ template more than once with concurrent calls to the `partialCached` function. After Hugo caches the rendered _partial_ template, new pages entering the build pipeline will use the cached result. +Within a _partial_ template, a path that begins with `./` or `../` is resolved relative to the calling _partial_ template. See [`partials.Include`](/functions/partials/include/#relative-paths).+ Here is the simplest usage: ```go-html-templatetpl/partials/partials.goindex f0906fb83..f27ba186e 100644@@ -111,6 +111,10 @@ func (ns *Namespace) Include(ctx context.Context, name string, contextList ...an } func (ns *Namespace) include(ctx context.Context, name string, dataList ...any) includeResult {+ name, err := ns.deps.TemplateStore.ResolvePartialName(ctx, name)+ if err != nil {+ return includeResult{err: err}+ } v, err := ns.lookup(name) if err != nil { return includeResult{err: err}@@ -181,6 +185,10 @@ func (ns *Namespace) doInclude(ctx context.Context, key string, templ *tplimpl.T // Note that ctx is provided by Hugo, not the end user. func (ns *Namespace) IncludeCached(ctx context.Context, name string, context any, variants ...any) (any, error) { start := time.Now()+ name, err := ns.deps.TemplateStore.ResolvePartialName(ctx, name)+ if err != nil {+ return nil, err+ } keyString := name if len(variants) > 0 { key := partialCacheKey{tpl/partials/partials_integration_test.goindex 72b5f62a5..477eb55ee 100644@@ -428,3 +428,134 @@ baseURL = 'http://example.com/' b.AssertFileContent("public/index.html", "42|") }++// See issue 15373.+func TestIncludeRelativePath(t *testing.T) {+ t.Parallel()++ files := `+-- hugo.toml --+disableKinds = ["section", "taxonomy", "term", "sitemap", "RSS"]+-- layouts/home.html --+{{ partial "a/b/main.html" . }}+{{ partial "c/main.html" . }}+{{ partial "inline.html" . }}+{{ define "_partials/a/inline.html" }}inline:{{ partial "./helper.html" . }}{{ end }}+-- layouts/_partials/inline.html --+{{ partial "a/inline.html" . }}+-- layouts/_partials/a/b/main.html --+same:{{ partial "./helper.html" . }}+sub:{{ partial "./sub/helper.html" . }}+parent:{{ partial "../helper.html" . }}+root:{{ partial "../../root.html" . }}+cached:{{ partialCached "./cached.html" . }}+dynamic:{{ partial (printf "./%s.html" "helper") . }}+include:{{ partials.Include "./helper.html" . }}+-- layouts/_partials/a/b/helper.html --+a/b/helper+-- layouts/_partials/a/b/sub/helper.html --+a/b/sub/helper+-- layouts/_partials/a/b/cached.html --+a/b/cached+-- layouts/_partials/a/helper.html --+a/helper+-- layouts/_partials/root.html --+root+-- layouts/_partials/c/main.html --+cached:{{ partialCached "./cached.html" . }}+-- layouts/_partials/c/cached.html --+c/cached+`++ b := hugolib.Test(t, files)++ b.AssertFileContent("public/index.html",+ "same:a/b/helper",+ "sub:a/b/sub/helper",+ "parent:a/helper",+ "root:root",+ "cached:a/b/cached",+ "dynamic:a/b/helper",+ "include:a/b/helper",+ "cached:c/cached",+ "inline:a/helper",+ )+}++func TestIncludeRelativePathInDecoratorInner(t *testing.T) {+ t.Parallel()++ files := `+-- hugo.toml --+disableKinds = ["section", "taxonomy", "term", "sitemap", "RSS"]+-- layouts/home.html --+{{ partial "a/main.html" . }}+-- layouts/_partials/a/main.html --+{{ with partial "b/wrapper.html" . }}{{ partial "./helper.html" . }}{{ end }}+-- layouts/_partials/a/helper.html --+a/helper+-- layouts/_partials/b/wrapper.html --+wrapper:{{ inner . }}+-- layouts/_partials/b/helper.html --+b/helper+`++ b := hugolib.Test(t, files)++ b.AssertFileContent("public/index.html", "wrapper:a/helper")+}++func TestIncludeRelativePathNotFromPartial(t *testing.T) {+ t.Parallel()++ files := `+-- hugo.toml --+disableKinds = ["section", "taxonomy", "term", "sitemap", "RSS"]+-- layouts/home.html --+{{ partial "./helper.html" . }}+-- layouts/_partials/helper.html --+helper+`++ b, err := hugolib.TestE(t, files)++ b.Assert(err, qt.ErrorMatches, `(?s).*relative partial path "./helper.html" can only be used from within a partial.*`)+}++func TestIncludeRelativePathOutsidePartials(t *testing.T) {+ t.Parallel()++ files := `+-- hugo.toml --+disableKinds = ["section", "taxonomy", "term", "sitemap", "RSS"]+-- layouts/home.html --+{{ partial "a/main.html" . }}+-- layouts/_partials/a/main.html --+{{ partial "../../helper.html" . }}+-- layouts/_partials/helper.html --+helper+`++ b, err := hugolib.TestE(t, files)++ b.Assert(err, qt.ErrorMatches, `(?s).*relative partial path "../../helper.html" in "_partials/a/main.html" resolves outside the partials directory.*`)+}++func TestIncludeRelativePathInDeferredBlock(t *testing.T) {+ t.Parallel()++ files := `+-- hugo.toml --+disableKinds = ["section", "taxonomy", "term", "sitemap", "RSS"]+-- layouts/home.html --+{{ partial "a/main.html" . }}+-- layouts/_partials/a/main.html --+{{ with (templates.Defer (dict "key" "a")) }}deferred:{{ partial "./helper.html" . }}{{ end }}+-- layouts/_partials/a/helper.html --+a/helper+`++ b := hugolib.Test(t, files)++ b.AssertFileContent("public/index.html", "deferred:a/helper")+}tpl/tplimpl/templatestore.goindex 4721c1f4a..b1aed169f 100644@@ -249,6 +249,9 @@ type TemplInfo struct { // The base template used, if any. base *TemplInfo + // For partial decorator inner templates, the template the inner block was defined in.+ decoratorOwner *TemplInfo+ // The descriptior that this template represents. D TemplateDescriptor @@ -636,6 +639,31 @@ func (s *TemplateStore) LookupPartial(pth string) *TemplInfo { return ti } +// ResolvePartialName resolves partial names starting with "./" or "../"+// relative to the directory of the calling partial.+func (s *TemplateStore) ResolvePartialName(ctx context.Context, name string) (string, error) {+ if !strings.HasPrefix(name, "./") && !strings.HasPrefix(name, "../") {+ return name, nil+ }+ cur := tpl.Context.CurrentTemplate.Get(ctx)+ if cur == nil {+ return "", fmt.Errorf("relative partial path %q can only be used from within a partial", name)+ }+ ti := cur.CurrentTemplateInfoOps.(*TemplInfo)+ for ti.decoratorOwner != nil {+ ti = ti.decoratorOwner+ }+ if ti.category != CategoryPartial {+ return "", fmt.Errorf("relative partial path %q can only be used from within a partial, called from %q", name, ti.Name())+ }+ dir := strings.TrimPrefix(strings.TrimPrefix(ti.PathInfo.Dir(), "/"+containerPartials), "/")+ resolved := path.Join(dir, name)+ if resolved == ".." || strings.HasPrefix(resolved, "../") {+ return "", fmt.Errorf("relative partial path %q in %q resolves outside the partials directory", name, ti.Name())+ }+ return resolved, nil+}+ func (s *TemplateStore) LookupShortcodeByName(name string) *TemplInfo { name = strings.ToLower(name) ti, _ := s.shortcodesByName.Get(name)@@ -939,10 +967,12 @@ func (t *TemplateStore) addDeferredTemplate(owner *TemplInfo, name string, n *pa } t.templatesByPath.Set(name, &TemplInfo{- Fi: owner.Fi,- PathInfo: owner.PathInfo,- D: owner.D,- Template: templ,+ Fi: owner.Fi,+ PathInfo: owner.PathInfo,+ D: owner.D,+ Template: templ,+ category: owner.category,+ decoratorOwner: owner.decoratorOwner, }) return niltpl/tplimpl/templatetransform.goindex dcb59abe7..3c37ea6ef 100644@@ -301,6 +301,7 @@ func (c *templateTransformContext) handleWithPartial(withNode *parse.WithNode) { c.err = fmt.Errorf("failed to find internal partial decorator template %q after insertion", internalPartialName) return }+ ti.decoratorOwner = c.t cc := newTemplateTransformContext(ti, c.store, c.lookupFn)