I have several go templates. The below examples are oversimplified, but it states my idea correctly. For example, I have
{{ define "div-block" }}
<div style="display:block">
.....
</div>
{{ end }}
Now I want to transfer any other template inside div-block
when using it, so that I could put anything inside div. E.g:
{{ template "div-block" . }}
{{ template "header" }}
{{ end }}
{{ template "div-block" . }}
<ul>
<li>1</li>
</ul>
{{ end }}
Where "header" is some other template.
Which is the the right way to do this with go template? Is it possible to do it with custom function? Is it possible to make custom actions
in go template? (actions can have end
statement and therefore the body, while functions are not)