Context for dynamically created partial file names

Let’s assume I have a file apple.html inside the partials folder as follows:

<h1>{{ .Site.Params.author.name }}</h1>
  1. In the first scenario, I can use it in index.html as {{ partial "apple" . }} and it works as expected.

  2. In the second scenario, I have a string array that I obtain from params in config.toml and use it to create the name of partial. The line of interest in the config.toml file would be something like:

[params]
[params.temp]
    fruits = ["apple"]

In the index.html I want to do something like

{{ range .Site.Params.temp.fruits }}
    {{ $var := . }}
    {{ partial $var <Context> }}
{{ end }}

What should I replace <Context> with so that everything works and I have to make no (or minimal) changes to the apple.html.

I tried by using {{ partial $var (dict "Mypage" $) }}. The following still didn’t work:

<h1>{{ .Mypage.Params.author.name }}</h1>

Have you tried just passing $? {{ $partial $var $ }}

1 Like

I should have…