Load .Page.Store. before load main block

Hello.
I’m trying conditonally load partial template by using .Page.Store.SetInMap in render hooks.
However, I can’t load .Page.Store value positioned before ‘main’ block.
Below code is my template

<!DOCTYPE html>
<html>
<head>
  <!-- ... -->
  {{- range $e, $v := (.Page.Store.Get "extension-header") }}
  {{- if $v -}}
    {{- partialCached ($e | printf "extension/header/%s.html") . -}}
  {{- end -}}
  {{- end -}}

  {{- block "metadata" . -}}{{- end -}}
</head>
<body>
  {{- block "main" . -}}{{- end -}}
  <!-- ... -->
</body>
</html>

In this code, can’t load “extension-header” value.
If “extension-header” is positioned after “main” block, it can load partial template normally.

Then, for solving this, I tried using other block like this:

<!DOCTYPE html>
<html>
<head>
  <!-- ... -->
  {{- block "extension-header" . -}}{{- end -}}

  {{- block "metadata" . -}}{{- end -}}
</head>
<body>
  {{- block "main" . -}}{{- end -}}
  {{- define "extension-header" . -}}
  {{- range $e, $v := (.Page.Store.Get "extension-header") }}
  {{- if $v -}}
    {{- partialCached ($e | printf "extension/header/%s.html") . -}}
  {{- end -}}
  {{- end -}}
  {{- end -}}
  <!-- ... -->
</body>
</html>

However, the result was the same.
Who have an idea for this?

Render the page contents before accessing the .Page.Store:

Thanks!

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.