Backtestshugorun-20261007-020926#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 implement the requested feature the same basic way. They resolve names beginning with './' or '../' against the calling partial's directory, walk up from decorator inner templates to the template the block was written in, and handle deferred blocks. Both also resolve the name before building the partialCached key, so same-named partials in different directories get separate cache entries. Both add integration tests that would fail without the change. Patch A is more robust at the edges: 1. Safe type handling. A uses a checked type assertion on CurrentTemplateInfoOps and checks for a nil PathInfo. B uses an unchecked `.(*TemplInfo)` assertion and calls `ti.PathInfo.Dir()` without a nil check, so an unexpected context could panic. 2. Less side-effect risk on deferred templates. A adds an `origin` back-pointer to the deferred template and leaves its other fields alone. B also copies the owner's `category` onto the deferred TemplInfo, a semantic change that other code keyed on category could observe, purely to make resolution work. 3. Degenerate names. A rejects names like './' and '../' with a clear error. B passes them through to `path.Join`. 4. Error messages. A's not-found error shows both the original and the resolved name. B only reports the resolved name, which can confuse users. 5. Tests. A covers more: cache-key separation for same-named partials in different directories, partialCached with variants, a theme partial resolving upward, extensionless names, and a table of error cases including partialCached called outside a partial. B's tests are good (dynamic names, decorator, deferred block, error cases) but narrower on errors. Scope is comparable; both update the docs. Overall, A is the more careful and better-tested fix.
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
20m
Wall-clock time in the container
Full test suite
No new failures
3,788 passed · 101 skipped · 3,891 total
Contamination audit
Clean
No sign the agent saw the real fix
Patch size
250vs 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
docs/content/en/functions/partials/Include.mdindex 58acbcc7f..efd38dfd9 100644@@ -74,5 +74,31 @@ To return a value from a _partial_ template, it must contain only one `return` s {{ return $result }} ``` +## Relative paths++The template name is relative to the `layouts/_partials` directory. Within a _partial_ template, a name beginning with `./` or `../` is relative to the directory of the calling _partial_ template instead:++```tree+layouts/+└── _partials/+ └── article/+ ├── header.html+ ├── meta.html+ └── utils/+ └── date.html+```++Within `layouts/_partials/article/header.html`:++```go-html-template+{{ partial "./meta.html" . }} {{/* layouts/_partials/article/meta.html */}}+{{ partial "./utils/date.html" . }} {{/* layouts/_partials/article/utils/date.html */}}+```++Within `layouts/_partials/article/utils/date.html`, use `{{ partial "../meta.html" . }}` to call `layouts/_partials/article/meta.html`.++A relative name cannot point outside of the `layouts/_partials` directory, and you cannot use a relative name outside of a _partial_ template. The same rules apply to the [`partialCached`][] function.++[`partialCached`]: /functions/partials/includecached/ [`return`]: /functions/go-template/return/ [breadcrumb navigation]: /content-management/sections/#ancestors-and-descendantstpl/partials/partials.goindex f0906fb83..9696d9313 100644@@ -20,6 +20,7 @@ import ( "errors" "fmt" "html/template"+ "path" "strings" "time" @@ -111,24 +112,64 @@ 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) {+// isRelativeName reports whether name is relative to the calling partial,+// e.g. "./foo.html" or "../foo.html".+func isRelativeName(name string) bool {+ return strings.HasPrefix(name, "./") || strings.HasPrefix(name, "../")+}++// resolveName resolves a partial name relative to the calling partial's+// directory if it starts with "./" or "../", otherwise name is returned as is.+func (ns *Namespace) resolveName(ctx context.Context, name string) (string, error) {+ if !isRelativeName(name) {+ return name, nil+ }+ var dir string+ var found bool+ if current := tpl.Context.CurrentTemplate.Get(ctx); current != nil {+ if ti, ok := current.CurrentTemplateInfoOps.(*tplimpl.TemplInfo); ok {+ dir, found = ti.PartialDir()+ }+ }+ if !found {+ return "", fmt.Errorf("partial %q: relative partial names can only be used from within a partial", name)+ }+ if base := path.Base(name); base == "." || base == ".." || strings.HasSuffix(name, "/") {+ return "", fmt.Errorf("partial %q: relative partial name must point to a file", name)+ }+ resolved := path.Join(dir, name)+ if resolved == ".." || strings.HasPrefix(resolved, "../") {+ return "", fmt.Errorf("partial %q: relative partial name resolves outside of the partials directory", name)+ }+ return resolved, nil+}++// lookup resolves name and returns the resolved name and its template.+func (ns *Namespace) lookup(ctx context.Context, name string) (string, *tplimpl.TemplInfo, error) { if strings.HasPrefix(name, "partials/") { // This is most likely not what the user intended. // This worked before Hugo 0.146.0. ns.deps.Log.Warnidf(constants.WarnPartialSuperfluousPrefix, "Doubtful use of partial function in {{ partial \"%s\"}}), this is most likely not what you want. Consider removing superfluous prefix \"partials/\" from template name given as first function argument.", name) }- v := ns.deps.TemplateStore.LookupPartial(name)+ resolved, err := ns.resolveName(ctx, name)+ if err != nil {+ return "", nil, err+ }+ v := ns.deps.TemplateStore.LookupPartial(resolved) if v == nil {- return nil, fmt.Errorf("partial %q not found", name)+ if resolved != name {+ return "", nil, fmt.Errorf("partial %q (resolved to %q) not found", name, resolved)+ }+ return "", nil, fmt.Errorf("partial %q not found", name) }- return v, nil+ return resolved, v, nil } // include is a helper function that lookups and executes the named partial.@@ -181,6 +222,13 @@ 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()+ depsManagerIn := tpl.Context.GetDependencyManagerInCurrentScope(ctx)+ // Relative names are resolved first, so the cache key is the same no matter where the partial is called from.+ name, ti, err := ns.lookup(ctx, name)+ if err != nil {+ return nil, err+ }+ keyString := name if len(variants) > 0 { key := partialCacheKey{@@ -190,12 +238,6 @@ func (ns *Namespace) IncludeCached(ctx context.Context, name string, context any keyString = key.Key() } - depsManagerIn := tpl.Context.GetDependencyManagerInCurrentScope(ctx)- ti, err := ns.lookup(name)- if err != nil {- return nil, err- }- if parent := tpl.Context.CurrentTemplate.Get(ctx); parent != nil { for parent != nil { if parent.CurrentTemplateInfoOps == ti && parent.Key == keyString {tpl/partials/partials_integration_test.goindex 72b5f62a5..d1643295e 100644@@ -428,3 +428,137 @@ baseURL = 'http://example.com/' b.AssertFileContent("public/index.html", "42|") }++func TestIncludeRelativePath(t *testing.T) {+ t.Parallel()++ files := `+-- hugo.toml --+baseURL = 'http://example.com/'+theme = 'mytheme'+-- layouts/home.html --+{{ partial "foo/bar/main.html" . }}|{{ partial "c.html" . }}+-- layouts/_partials/foo/bar/main.html --+same:{{ partial "./a.html" . }}|sameNoExt:{{ partial "./a" . }}|sub:{{ partial "./sub/b.html" . }}|up:{{ partial "../c.html" . }}|cached:{{ partialCached "./a.html" . }}|cachedVariant:{{ partialCached "./a.html" . "v1" }}|ns:{{ partials.Include "./a.html" . }}|theme:{{ partial "./t.html" . }}|inline:{{ partial "./inline.html" . }}+{{ define "_partials/foo/bar/inline.html" }}inline:{{ partial "./a.html" . }}{{ end }}+-- layouts/_partials/foo/bar/a.html --+foo/bar/a+-- layouts/_partials/foo/bar/sub/b.html --+foo/bar/sub/b:{{ partial "../a.html" . }}+-- layouts/_partials/foo/c.html --+foo/c+-- layouts/_partials/c.html --+root/c+-- themes/mytheme/layouts/_partials/foo/bar/t.html --+theme:{{ partial "../c.html" . }}+`++ b := hugolib.Test(t, files)++ b.AssertFileContent("public/index.html",+ "same:foo/bar/a\n|sameNoExt:foo/bar/a\n|sub:foo/bar/sub/b:foo/bar/a\n\n|up:foo/c\n|cached:foo/bar/a\n|cachedVariant:foo/bar/a\n|ns:foo/bar/a\n|theme:theme:foo/c\n\n|inline:inline:foo/bar/a\n",+ "|root/c",+ )+}++func TestIncludeCachedRelativePathSameNameDifferentDirs(t *testing.T) {+ t.Parallel()++ files := `+-- hugo.toml --+baseURL = 'http://example.com/'+-- layouts/home.html --+{{ partial "a/main.html" . }}|{{ partial "b/main.html" . }}|{{ partialCached "a/x.html" . }}+-- layouts/_partials/a/main.html --+a:{{ partialCached "./x.html" . }}+-- layouts/_partials/b/main.html --+b:{{ partialCached "./x.html" . }}+-- layouts/_partials/a/x.html --+a/x+-- layouts/_partials/b/x.html --+b/x+`++ b := hugolib.Test(t, files)++ b.AssertFileContent("public/index.html", "a:a/x\n\n|b:b/x\n\n|a/x\n")+}++func TestIncludeRelativePathInPartialDecorator(t *testing.T) {+ t.Parallel()++ files := `+-- hugo.toml --+baseURL = 'http://example.com/'+-- layouts/home.html --+{{ partial "foo/main.html" . }}+-- layouts/_partials/foo/main.html --+{{ with partial "../wrap.html" . }}inner:{{ partial "./a.html" . }}{{ end }}+-- layouts/_partials/wrap.html --+<b>{{ inner . }}</b>+-- layouts/_partials/foo/a.html --+foo/a+-- layouts/_partials/a.html --+root/a+`++ b := hugolib.Test(t, files)++ b.AssertFileContent("public/index.html", "<b>inner:foo/a\n</b>")+}++func TestIncludeRelativePathInDeferredBlock(t *testing.T) {+ t.Parallel()++ files := `+-- hugo.toml --+baseURL = 'http://example.com/'+-- layouts/home.html --+{{ partial "foo/main.html" . }}+-- layouts/_partials/foo/main.html --+{{ with (templates.Defer (dict "key" "relative")) }}deferred:{{ partial "./a.html" . }}{{ end }}+-- layouts/_partials/foo/a.html --+foo/a+-- layouts/_partials/a.html --+root/a+`++ b := hugolib.Test(t, files)++ b.AssertFileContent("public/index.html", "deferred:foo/a")+}++func TestIncludeRelativePathErrors(t *testing.T) {+ t.Parallel()++ for _, test := range []struct {+ name string+ home string+ partial string+ expect string+ }{+ {"not in partial", `{{ partial "./a.html" . }}`, ``, `relative partial names can only be used from within a partial`},+ {"not in partial cached", `{{ partialCached "./a.html" . }}`, ``, `relative partial names can only be used from within a partial`},+ {"outside partials dir", `{{ partial "foo/main.html" . }}`, `{{ partial "../../a.html" . }}`, `relative partial name resolves outside of the partials directory`},+ {"not found", `{{ partial "foo/main.html" . }}`, `{{ partial "./nope.html" . }}`, `partial "./nope.html" (resolved to "foo/nope.html") not found`},+ {"current dir", `{{ partial "foo/main.html" . }}`, `{{ partial "./" . }}`, `relative partial name must point to a file`},+ {"parent dir", `{{ partial "foo/main.html" . }}`, `{{ partial "../" . }}`, `relative partial name must point to a file`},+ } {+ t.Run(test.name, func(t *testing.T) {+ t.Parallel()+ files := `+-- hugo.toml --+baseURL = 'http://example.com/'+-- layouts/home.html --+` + test.home + `+-- layouts/_partials/foo/main.html --+` + test.partial + `+-- layouts/_partials/a.html --+a+`+ b, err := hugolib.TestE(t, files)+ b.Assert(err, qt.IsNotNil)+ b.Assert(err.Error(), qt.Contains, test.expect)+ })+ }+}tpl/tplimpl/templatestore.goindex 4721c1f4a..6397c06e4 100644@@ -263,12 +263,35 @@ type TemplInfo struct { // processing state. state processingState isLegacyMapped bool++ // For internal partial decorator templates, this is the template+ // the decorated block was written in.+ origin *TemplInfo } func (ti *TemplInfo) SubCategory() SubCategory { return ti.subCategory } +// PartialDir returns the directory of this partial template relative to the+// partials root, e.g. "foo/bar" for layouts/_partials/foo/bar/baz.html.+// For internal partial decorator templates, the template the decorated block+// was written in is used.+// The second return value is false if that template is not a partial.+func (ti *TemplInfo) PartialDir() (string, bool) {+ for ti.origin != nil {+ ti = ti.origin+ }+ if ti.category != CategoryPartial || ti.PathInfo == nil {+ return "", false+ }+ rel, ok := strings.CutPrefix(ti.PathInfo.Path(), "/"+containerPartials+"/")+ if !ok {+ return "", false+ }+ return path.Dir(rel), true+}+ func (ti *TemplInfo) BaseVariantsSeq() iter.Seq[*TemplWithBaseApplied] { return func(yield func(*TemplWithBaseApplied) bool) { for _, v := range ti.baseVariants.All() {@@ -943,6 +966,7 @@ func (t *TemplateStore) addDeferredTemplate(owner *TemplInfo, name string, n *pa PathInfo: owner.PathInfo, D: owner.D, Template: templ,+ origin: owner, }) return niltpl/tplimpl/templatetransform.goindex dcb59abe7..cd81efe79 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 inside the block resolve against the template it was written in.+ ti.origin = c.t cc := newTemplateTransformContext(ti, c.store, c.lookupFn)
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)