Should it be possible to have blocks in partials?

In a baseof setting, I have a partials/head.html partial. There I have a

{{ block "head" . }} {{ end -}}

When I try to write something to it from layout/single.html,
like this:

    {{- define "main" }}
    {{ template "partials/article.html" . }}
    {{- end }}
    {{- define "head" }}
    alert('Hello World!');
    {{- end }}

nothing renders.
How come?

Please post more of your code.

  • What would you expect to render where?
  • What’s happening in partials/article.html?
  • Where is main defined?
  • What’s up with those backslashes before the script tags? If you expect an alert to pop up then try removing them.
  • Do you have a CSP deployed that disallows inline javascript?

You are right, of course, this was a lazy way to ask. However, one always hopes, that one’s error is a known and easily identifiable one.

So I built a small site to show it. it is on github.

I put a block in layouts/partial/head.html (at the bottom) and reference to it from layouts/index.html.

The content never shows up.

I hope this clears things up. I had to put these slashes here in the forum textbox for the script tags to show up.

No, it’s not possible.

Ok, good to know. Thanks! Would be great if it was implemented some day, though.