Id like to be able to have multiple levels of nested templates.
I have my _default/baseof.html for the site which has a “main” block… all well and good. However I’m building out my sections and I’m encountering a lot of repetition.
For each section, I have the following in section/list.html:
{{ define "main" }}
<section class="container my-2" style="max-width: 700px !important">principles/list</section>
<section class="container my-2" style="max-width: 700px !important"><!-- headline -->{{ partial "infrastructure/breadcrumbs.html" . }}</section>
{{ partial "headline.html" . }}
<section class="container my-5">
<h2 title="title?">title</h2>
<p>
Thig àm nuair a dh’fhalbhas an t-acras agus thèid an t-uisge a-mach air an talamh. Bidh a h-uile càil air a chùlaibh, agus seasaidh an latha ri teachd mar theine ann an adhar gorm. Cumaidh iad suas an sgàil agus cuiridh iad air falbh an t-eagal a
bh’ aca, oir chan eil dòigh air faighinn air ais an t-àm a chaidh seachad. Cuiridh iad an aire air adhart gu coilltean mòra agus sruthan glan, a’ sireadh sìth an cois an nàdur.
</p>
{{ partial "cards-section.html" (dict "context" . "SectionName" "principles") }}
</section>
{{ partial "connect.html" . }}
{{ partial "our-customers.html" . }}
{{ end }}
The html section with the “title” is the only difference for these high-level section pages as I store the rest of the differences in the front matter.
What I would like to do is have a template that inherits from _default/baseof.html and implements:
{{ define "main" }}
<section class="container my-2" style="max-width: 700px !important">principles/list</section>
<section class="container my-2" style="max-width: 700px !important"><!-- headline -->{{ partial "infrastructure/breadcrumbs.html" . }}</section>
{{ partial "headline.html" . }}
{{ block "weeBit" . }}{{ end }}
{{ partial "connect.html" . }}
{{ partial "our-customers.html" . }}
{{ end }}
This way my section/list.html would only need to have:
{{ define "weeBit" }}
<section class="container my-5">
<h2 title="title?">title</h2>
<p>
Thig àm nuair a dh’fhalbhas an t-acras agus thèid an t-uisge a-mach air an talamh. Bidh a h-uile càil air a chùlaibh, agus seasaidh an latha ri teachd mar theine ann an adhar gorm. Cumaidh iad suas an sgàil agus cuiridh iad air falbh an t-eagal a
bh’ aca, oir chan eil dòigh air faighinn air ais an t-àm a chaidh seachad. Cuiridh iad an aire air adhart gu coilltean mòra agus sruthan glan, a’ sireadh sìth an cois an nàdur.
</p>
{{ partial "cards-section.html" (dict "context" . "SectionName" "principles") }}
</section>
{{ end }}
I’m just not sure I understand how to do this…
GitRepo: nkdAgility/NKDAgility.com at topic/17-develop-list-pages (github.com)