File tree 2 files changed +28
-1
lines changed
2 files changed +28
-1
lines changed Original file line number Diff line number Diff line change 279
279
b .Assert (err , qt .IsNotNil )
280
280
b .Assert (err .Error (), qt .Contains , "wrong number of args for string: want 1 got 0" )
281
281
}
282
+
283
+ func TestPartialWithoutSuffixIssue13601 (t * testing.T ) {
284
+ t .Parallel ()
285
+
286
+ files := `
287
+ -- hugo.toml --
288
+ -- layouts/home.html --
289
+ P1: {{ partial "p1" . }}
290
+ P2: {{ partial "p2" . }}
291
+ -- layouts/_partials/p1 --
292
+ P1.
293
+ -- layouts/_partials/p2 --
294
+ P2.
295
+ {{ return "foo bar" }}
296
+
297
+ `
298
+
299
+ b := hugolib .Test (t , files )
300
+ b .AssertFileContent ("public/index.html" , "P1: P1.\n P2: foo bar" )
301
+ }
Original file line number Diff line number Diff line change @@ -913,7 +913,7 @@ func (s *TemplateStore) extractInlinePartials() error {
913
913
name := templ .Name ()
914
914
if ! paths .HasExt (name ) {
915
915
// Assume HTML. This in line with how the lookup works.
916
- name = name + ".html"
916
+ name = name + s . htmlFormat . MediaType . FirstSuffix . FullSuffix
917
917
}
918
918
if ! strings .HasPrefix (name , "_" ) {
919
919
name = "_" + name
@@ -1092,6 +1092,12 @@ func (s *TemplateStore) insertTemplate2(
1092
1092
panic ("category not set" )
1093
1093
}
1094
1094
1095
+ if category == CategoryPartial && d .OutputFormat == "" && d .MediaType == "" {
1096
+ // See issue #13601.
1097
+ d .OutputFormat = s .htmlFormat .Name
1098
+ d .MediaType = s .htmlFormat .MediaType .Type
1099
+ }
1100
+
1095
1101
m := tree .Get (key )
1096
1102
nk := nodeKey {c : category , d : d }
1097
1103
@@ -1719,6 +1725,7 @@ func (s *TemplateStore) transformTemplates() error {
1719
1725
continue
1720
1726
}
1721
1727
if ! vv .noBaseOf {
1728
+ // TODO(bep) I don't think this branch is ever called.
1722
1729
for vvv := range vv .BaseVariantsSeq () {
1723
1730
tctx , err := applyTemplateTransformers (vvv .Template , lookup )
1724
1731
if err != nil {
You can’t perform that action at this time.
0 commit comments