Hello,
Is it possible to check if a block is empty within a partial file, or anywhere else for that matter?
Here is the relevant portion of my baseof.html
template:
{{ partial "navigation.html" . }}
<div class="main-container">
{{ block "header" . }}{{ end }}
<main>
{{ block "main" . }}{{ end }}
</main>
{{ partial "footer.html" . }}
</div>
I have a partial template called navigation.html
. In it, i’d like to do something like this:
<nav{{ if ne "header" "" }} class="special-class"{{ end }}>
In other words, if there is something defined for the header
block, add a class (or do whatever). Otherwise, if there’s nothing in the header block, don’t do anything.
Thanks y’all for considering this question. Please forgive me if it’s obvious and i missed it.